Docker群从外部网络获得访问



我有4个Proxmox LXC虚拟容器与Ubuntu 22.04。相应的docker集群节点

sudo docker node ls
ID                            HOSTNAME         STATUS    AVAILABILITY   MANAGER STATUS   ENGINE VERSION
lk0nxl4bh6hbt8v8f30v08y6s *   vm-swarm-1-1   Ready     Active         Leader           20.10.22
09amzoukr1wpuw7svvic79ai2     vm-swarm-1-2   Ready     Active                          20.10.22
lgmu00c5cgqw12satg7txb6ba     vm-swarm-1-3   Ready     Active                          20.10.22
pv1v3whrotxduv40cw911qguh     vm-swarm-1-4   Ready     Active                          20.10.22

我的服务在docker- composition .yaml中描述文件:

version: '3'
services:
php_test:
image: nanoninja/php-fpm:8.1
container_name: phpfpm
restart: always
ports:
- "3030:3030"
command: php -S="0.0.0.0:3030" -t="/var/www/html"

我用命令部署堆栈:

sudo docker stack deploy -c ./docker-compose.yaml php_test
Ignoring unsupported options: restart
Ignoring deprecated options:
container_name: Setting the container name is not supported.
Creating network php_test_default
Creating service php_test_php_test

我检查我的堆栈是否与命令一起工作:

sudo docker stack ls
NAME       SERVICES   ORCHESTRATOR
php_test   1          Swarm
prod       1          Swarm
viz        1          Swarm

sudo docker stack services php_test
ID             NAME                MODE         REPLICAS   IMAGE                   PORTS
6gcfr5zfm5hn   php_test_php_test   replicated   1/1        nanoninja/php-fpm:8.1   *:3030->3030/tcp

docker群网络是这样的:

sudo docker network ls 
NETWORK ID     NAME               DRIVER    SCOPE
c23af3b0a95b   bridge             bridge    local
30b132f70f88   docker_gwbridge    bridge    local
680262af3a30   host               host      local
iu9hug3kt509   ingress            overlay   swarm
1674e3ce429c   none               null      local
yfir1163z01i   php_test_default   overlay   swarm
p9h6n1bjlanq   prod_default       overlay   swarm
kqr5aj2cbe6s   viz_default        overlay   swarm

Ubuntu和Proxmox防火墙被禁用。从表面上看,堆栈是可用的。但是当我试图访问堆栈时,我被拒绝了:

curl -i 'http://192.168.0.151:3030'
curl: (7) Failed to connect to 192.168.0.151 port 3030 after 0 ms: Connection refused
curl -i 'http://192.168.0.152:3030'
curl: (7) Failed to connect to 192.168.0.152 port 3030 after 0 ms: Connection refused
curl -i 'http://192.168.0.153:3030'
curl: (7) Failed to connect to 192.168.0.153 port 3030 after 0 ms: Connection refused
curl -i 'http://192.168.0.154:3030'
curl: (7) Failed to connect to 192.168.0.154 port 3030 after 0 ms: Connection refused
如何启动PHPstack ondocker swarm在之外正确地访问

网络?注意:如果可能的话,我想做而不做Nginx.

我花了几个星期的时间。最后,通过为ingress_sbox命名空间启用ip_forward,我能够访问Proxmox LXC上的Docker Swarm

在LXC容器内运行nsenter --net=/run/docker/netns/ingress_sbox sysctl -w net.ipv4.ip_forward=1

裁判:https://discuss.linuxcontainers.org/t/docker-swarm-in-lxd-container/937

经过多日的研究,我负责任地宣布。目前(2023-01-06)是不可能的使用Docker swarmProxmox LXC。以下是需要确认的答案:

https://github.com/portainer/portainer/issues/7736

LXC容器中的Docker群

如果你找到一个在Proxmox LXC上启动Docker集群的解决方案,不能保证你的集群不会崩溃。

相关内容

  • 没有找到相关文章

最新更新