Skip to content

Cannot access randomly selected port #527

Open
@kaskavalci

Description

@kaskavalci

When a container is started without host port, it is not accessible via lima.

$ docker run -d -p 80 nginx:alpine
aece04c330bd262ab2ab6b07bb8f30f41b5ce96aab2339ae743689ae093ccd88
$ docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED                  STATUS        PORTS                                     NAMES
aece04c330bd   nginx:alpine   "/docker-entrypoint.…"   Less than a second ago   Up 1 second   0.0.0.0:49198->80/tcp, :::49198->80/tcp   adoring_meninsky
$ curl localhost:49198
curl: (7) Failed to connect to localhost port 49198: Connection refused

It seems even though they are started with a specific host port, when that port was used before, it is still not available.

$ docker run -d -p 49200:80 nginx:alpine
dbd434293baa57f5c79b6260e2c0b800df90ee9bd46c2cf8ecc6ff1343cf588c
$ curl localhost:49200
curl: (7) Failed to connect to localhost port 49200: Connection refused
$ docker run -d -p 49300:80 nginx:alpine
ce99f09ba568d8d974bdd288fa03bf87797a2b23c32527d37490beb7ecd1ea02
$ curl --head localhost:49300
HTTP/1.1 200 OK
Server: nginx/1.21.5
Date: Thu, 06 Jan 2022 15:05:01 GMT
Content-Type: text/html
Content-Length: 615
Last-Modified: Tue, 28 Dec 2021 18:48:00 GMT
Connection: keep-alive
ETag: "61cb5be0-267"
Accept-Ranges: bytes

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions