New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do you map a port on running container? #4942
Comments
thanks, any progress? |
You can't change a port mapping on a running container, but you can stop the container and restart using the |
@mstanleyjones |
You're right, you'd run the docker run -d -p 4000:4000 --name mytest mistytest
docker container stop mytest
docker container start mytest # same port
docker container stop mytest
docker container run -p 4001:4000 mytest # Now mapping container port 4000 to host port 4001 |
@mstanleyjones |
You need to specify image name correctly which is
|
Thanks, but we talk about remaping port for a container, the "some-mysql" is that container which want to remaping port. docker run -p would create a new container not modify the old one. |
I will try to be more clear.
|
Tried and tested.
|
@JonathanAlumbaugh Make a search on your machine for |
@sadjunky In my case, |
Haven't checked, will try this out. Thanks for the heads up! |
I edit the
|
i guess its not ExposedPort inside config.v2.json rather its Ports. Also when i did |
how can I stop port of a docker, running container. |
Use dockerFile can solve this problem. More pls see the link: https://bobcares.com/blog/docker-change-container-configuration/ |
The same happened to me because I made a mistake (typo) in the configuration, and when I fixed it the container reappeared (after restarting docker). It should probably be the same for you. |
Can you give the location for Mac OSX please ? Thanks |
@HamaniKhalil ref: moby/moby#28283 |
An alternative to the above option of exposing port on a running container from the host machine is to create an image from the container. Then run the newly created image with desired ports to create a container with the port bindings
Note: Editing the container config files and stopping the docker for such modification might results into unwanted issues. I prefer this option rather than editing the config files. |
Is there a way to change ports without recreating the containers on a mac with docker-compose and a yml? It's very very time consuming to recreate all the networked dockers when you want to test port changes. This did not work for me @alexleekt
|
On runnning container, want to export a port outside, Any ways can quick reach it ?
docker commit and new a container is not a good idea in my stuation.
iptables seems can not take effect.
The text was updated successfully, but these errors were encountered: