When I do a docker swarm leave, all port mapping from any standalone container is removed. The containers themselves keep running, and I can restart them to recover from the issue. I’d expect standalone containers to stay unaffected by swarm nodes/services in general.
Am I understanding something wrong or Is this a known bug?
I should add that actually only containers started via docker-compose seem affected. When preparing a test case that uses the docker command line to start a simple nginx, the issue wasn’t reproducible. I could reproduce it on a simple nginx docker-compose.yaml however.
I am very interested in this issue, as new Traefik v3 enables local and swarm containers.
I tried to reproduce in a fresh Debian VM, but I don’t see ports removed as in not working anymore.
# Update Debian
sudo apt update
sudo apt -y upgrade
# Install Docker
curl -fsSL https://get.docker.com | sh -
# Run independent Docker container on port 80
docker run -d -p 80:80 --name whoami80 traefik/whoami
# Run independent Docker container on port 8080 with compose
cat << EOF > docker-compose.yml
version: '3'
services:
whoami8080:
image: traefik/whoami
container_name: whoami8080
ports:
- 8080:80
EOF
docker compose up -d
# Check independent Docker containers
docker ps
curl http://localhost
curl http://localhost:8080
# Wait 1 minute to get a meaningful uptime
echo sleep 65
sleep 65
# Init Docker Swarm
docker swarm init
# Wait 10 secs to settle
echo sleep 10
sleep 10
# Remove Swarm
docker swarm leave --force
# Check independent Docker containers
docker ps
curl http://localhost
curl http://localhost:8080
# Wait 10 secs to settle
echo sleep 10
sleep 10
# Check independent Docker containers
docker ps
curl http://localhost
curl http://localhost:8080
It always shows this, before and after swarm:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b7e41cfb6dc5 traefik/whoami "/whoami" About a minute ago Up About a minute 0.0.0.0:8080->80/tcp, :::8080->80/tcp whoami8080
dc000729ef56 traefik/whoami "/whoami" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp whoami80
I just tried your docker-compose example (not the docker CLI) on Docker version 24.0.5, build 24.0.5-0ubuntu1~22.04.1 and docker-compose version 1.29.2, build unknown – it reproduced the issue.