-
Notifications
You must be signed in to change notification settings - Fork 693
Open
Labels
Description
Description
I noticed that when I start two separate Lima VMs and try to start Docker containers on them with automatically assigned host ports, they end up listening to the same ports (!).
It seems to happen silently. To repro, first start a container called docker1
:
limactl start template://docker --name docker1
export DOCKER_HOST=$(limactl list docker1 --format 'unix://{{.Dir}}/sock/docker.sock')
docker run -d -p 80 nginx
docker ps -a
...
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
224e25506de7 nginx "/docker-entrypoint.…" 1 second ago Up 1 second 0.0.0.0:32768->80/tcp, [::]:32768->80/tcp silly_tu
Now, let's do it a second time with the name docker2
:
limactl start template://docker --name docker2
export DOCKER_HOST=$(limactl list docker2 --format 'unix://{{.Dir}}/sock/docker.sock')
docker run -d -p 80 nginx
docker ps -a
...
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a82de0b1db16 nginx "/docker-entrypoint.…" Less than a second ago Up Less than a second 0.0.0.0:32768->80/tcp, [::]:32768->80/tcp goofy_euler
As you can see, now I have two containers that both claim to be forwarding port 32768. In practice I believe the first one wins, and you aren't able to access the second container. Also, it's odd that it is picking exactly 2^15 for the number.
I'm on Lima 1.1.1 and macOS Sequoia 15.5 (Apple silicon).