Home > Enterprise >  Docker swarm get access from outside network
Docker swarm get access from outside network

Time:01-07

I have 4 Proxmox LXC virtual containers with Ubuntu 22.04. The corresponding docker swarm nodes are placed on them:

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

My services are described in a docker-compose.yaml file:

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"

I deploy the stack with a command:

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

I check that my stack is working with commands:

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

and

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

The docker swarm networks look like this:

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 and Proxmox firewall are disabled. In appearance, the stack is available. But when I try to access the stack, I get denied:

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

Question: How to start the PHP stack on docker swarm correctly to get access from outside network?

Note: If possible, I want to do without the Nginx.

CodePudding user response:

After spending many days of research, I responsibly declare. At the moment (2023-01-06) it is not possible to use the Docker swarm on the Proxmox LXC. Here are the answers to confirm:

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

Docker swarm in LXC containers

If you find a workaround to launch a Docker swarm on the Proxmox LXC, there is no guarantee that your swarm will not fall.

  • Related