0

running containersall containers I've recently started learning docker and after following the tutorial, I ran the following command

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

and open up port localhost:80 and saw the docker getting started page. However, I had to run my client's project, whose port was mapped to localhost:80 as well. On account of this, I'm unable to run my client's project on localhost:80. In addition to that, any instance I randomly open up docker and then switch to localhost:80, it redirects to docker's getting started tutorial. I want to reset this localhost:80 port so that when I run my client's project, I can map them to localhost:80. Any method to rectify the issue?

Elroy Toscano
  • 163
  • 1
  • 2
  • 8

4 Answers4

1

First find you container's ID using:

docker ps

Supposing it is e11d9f8bb730, you can now stop and remove the container with:

docker stop e11d9f8bb730
docker rm e11d9f8bb730

Run again your container, this time using a different port:

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

Now your container is running on port 81 and you will be able to run your client's App on port 80.

programandoconro
  • 1,704
  • 2
  • 11
  • 26
0

All you have to do is stop the container you just started (docker / getting-started). You can open a command prompt, then type this command:

docker container ls

You can see which containers are currently running. For example:

docker containers list

You just need to do this command for the stop container:

docker container stop *yourContainerName*

Dharman
  • 26,923
  • 21
  • 73
  • 125
0

You can use docker to map the container port to any port you choose on your local machine. As an example, you could use your docker getting started and map the port to 8080 instead of 80 like this:

docker run -d -p 127.0.0.1:8080:80/tcp docker/getting-started
Dominic Holt
  • 162
  • 1
  • 12
  • Tried it... localhost:80 maps to http://localhost/tutorial/ which is still docker's getting started;localhost:8080 is also mapped to docker's getting started – Elroy Toscano May 12 '21 at 12:03
  • Are you maybe running two instances of the container? What do you get when you type in `docker ps` - I just tried this exact command above and it worked for me. – Dominic Holt May 26 '21 at 05:25
0

My solution to this issue was so simple yet so incredibly annoying, I'm commenting here in case it helps anyone else. It was browser caching. So opening up dev tools and hard refreshing on localhost solved my issue with this.

jmorell
  • 3
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community May 20 '22 at 01:30