Docker swarm / service do not bind on ipv4 only on ipv6!

Setup 2 VMs with Ubuntu 22.04, then updated to 23 and installed Docker via convenience script.

sudo apt update && sudo apt upgrade -y
sudo nano /etc/update-manager/release-upgrades # Prompt=LTS -> Prompt=normal
sed -i 's/jammy/lunar/g' /etc/apt/sources.list
cat /etc/os-release

reboot

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

docker swarm init --advertise-addr 1.2.3.4
# docker swarm join ...

wget https://raw.githubusercontent.com/bluepuma77/traefik-best-practice/main/docker-swarm-traefik/docker-compose.yml
docker stack deploy -c docker-compose.yml traefik

# netstat -tulpn
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      2060/docker-proxy
tcp        0      0 127.0.0.54:53           0.0.0.0:*               LISTEN      417/systemd-resolve
tcp        0      0 0.0.0.0:443             0.0.0.0:*               LISTEN      2018/docker-proxy
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      417/systemd-resolve
tcp6       0      0 :::80                   :::*                    LISTEN      2071/docker-proxy
tcp6       0      0 :::22                   :::*                    LISTEN      1/init
tcp6       0      0 :::443                  :::*                    LISTEN      2032/docker-proxy

For me it works.

I may finally found the culprit of the story on running docker on … LXC container in proxmox !

It seems that docker is running fine but as soon as you use swarm, it seems that then completly broken !

The advice was to run docker in vm !

I will try this and return here to give my conclusion …

Did install a VM with lite linux distribution Alpine, and install docker ! Same problem no binding on ipv4 …

I give up for now … swarm get me crazy !

Have you tried with plain Ubuntu 22 in your infrastructure?

Bard says there might be relevant changes:

Yes, there are a few firewall changes in Ubuntu 23. The most notable change is that UFW is now enabled by default. This means that all incoming and outgoing traffic will be blocked by default, unless you explicitly allow it.

Did not try with Ubuntu 22 but with a much lighter linux distribution Alpine Linux (small footprint) in VM, same problem with swarm … only binding on IPv6 … I will try with Ubuntu 22 as soon as i have free time …

Just install Ubuntu 22 and docker packages from ubuntu repository and same problem only binding on IPv6 in swarm mode …

What’s your infrastructure around?

As stated above, I did fresh installs of Ubuntu 22/23 with updates and a fresh Swarm install on 2 Cloud-VMs and it worked.

I’m running a cluster 3 nodes proxmox with ceph storage.

Running Ubuntu 22 & 23 with apparmor running …

I created a VM with Ubuntu 22 & 23, and installed docker using the standard ubuntu repository with the following command :

apt-get install docker.io docker-compose

After that docker is running in standalone mode and i can create a container using portainer/portainer-ce for example …

After i launch the following command to be in swarm mode

docker swarm join init

This give me a docker node with a Leader/Manager.

Trying the following command

docker stack deploy --compose-file docker-compose.yml portainer-ce

This command create de stack with a service

After that if i run netstat -tapeu

This command only give IPv6 connection for the port exposed !

Same thing for lsof -i -n

I will try again to install docker without using default Ubuntu repository but installing from the script ofered by docker

Please, format your posts according to the following guide: How to format your forum posts
In short: please, use </> button to share codes, terminal outputs, error messages or anything that can contain special characters which would be interpreted by the MarkDown filter. Use the preview feature to make sure your text is formatted as you would expect it and check your post after you have sent it so you can still fix it.

It can get you much more answers.

I’ve the same problem with ubuntu 22.04 and 23.04, and i’ve found another post dated 2021 with the same problem but without reply

Can you share that post? It might give someone a new idea.

Here: https://forums.docker.com/t/bug-docker-swarm-ports-available-on-ipv6-only/114990

Thank you. I still can’t answer, but the in this post:

It’s clear that Docker was not installed from the official repository provided by Docker. The proper installation way is in the documentation.

For ubuntu:

I finally had time to test again docker swarm in VM using the script helper describe in de documentation using debian 12 … get-docker.sh

After docker swarm join

I ran

docker stack deploy --compose-file docker-compose.yml portainer-ce

my docker compose-file is


version: "3"
services:
  portainer:
    image: portainer/portainer-ce:latest
    container_name : portainer-ce
    ports:
      - 9443:9443
    volumes:
        - ./persist/data:/data
        - /var/run/docker.sock:/var/run/docker.sock
    restart: unless-stopped

Container is not reachable !

netstat connection only give tcp6 for port 9443 !

Docker VM is running on Proxmox !

What do you mean by “is not reachable”?

What’s the error? From which program? From the Internet, from outside Proxmox, from a VM inside Proxmox, from inside a Docker container? How do you expose ports to the outside of the VMs or outside your Proxmox host?

I have also this problem, any update about this issue ? :wink:

How do you know that it’s only IP6 and not IP4?

We might have the same issue: Swarm manager address not bound to IPv4 but only IPv6 · Issue #46851 · moby/moby · GitHub

Note: we discussed this topic before, we found that netstat not necessarily always shows the used IPv4 ports when using IPv6 ports at the same time, but they are still open.

I had no time to actually search further for this problem …

But note that not only

netstat -tupe

command do not give ipv4 connection but the command

lsof -i -n

give the same result, no listening on ipv4 !

So i think the problem is somewhere with docker swarm / or os / or virtualization layer