Stan
Stan

Reputation: 872

Docker port localhost:80 is always listened on

I am just studying the Docker and found out it seems that we don't need to run docker-tutorial image and the port:80 is always listened on just like below picture: docker tutorial

At first, I thought it is automatically managed by Docker Desktop. But it is not. Because after I close the Docker desktop completely, it is still there. I even run a command to check the process of port 80 and no process is there: check port 80 when no process is on this port, it is still running. It drives me crazy. I do have followed docker start tutorial to run this tutorial web application and at that time I can also open localhost:80. After that, I have stopped and removed container and even the image as well as closing the Docker app, the page, however, is still there. Does any have encountered this situation or have any idea? How does Docker do this?

After a day, i start my mac again without running Docker and it is still there in a messy way: messy one

Upvotes: 2

Views: 6686

Answers (4)

Brainmaniac
Brainmaniac

Reputation: 2556

I you came here when trying to do the first command in the tutorial and you got the error:

 Error response from daemon: Ports are not available: listen tcp 0.0.0.0:8080: bind: address already in use.

You need to change the first 80 to something else that is not used by your computer the 80:80 means "map the host port":"to this container port".

So try:

docker run -d -p 8081:80 docker/getting-started

Upvotes: 0

ViajanDee
ViajanDee

Reputation: 684

By the looks of the page, it is running off the browser cache. Clear the cache or open an incognito window to use the newly created services on port 80.

Upvotes: 4

Soo Na
Soo Na

Reputation: 1

I had the same issue but in my case it' was just a cache in the browser. After stopping the docker image or deleted it, it will work probably

For stop it. $ docker stop [CONTAINER ID] for delete it $ docker rm [CONTAINER ID]

Upvotes: 0

dsluo
dsluo

Reputation: 36

Try stopping the container. E.g.

  1. List running containers.
$ docker ps

CONTAINER ID        IMAGE                    COMMAND                  CREATED              STATUS              PORTS                NAMES
4b223e7cc8c5        docker/getting-started   "/docker-entrypoint.…"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp   wonderful_goldstine
  1. Stopping the docker/getting-started container with its container ID.
$ docker stop 4b223e7cc8c5

4b223e7cc8c5
  1. At this point, the container will have stopped and port 80 will be free. It will still be on your machine if you ever want to restart it, but you can remove it with:
$ docker rm 4b223e7cc8c5

4b223e7cc8c5

Upvotes: 0

Related Questions