I'm running a container (let's call it old_container
) with exposed
port 80 and bind the port to the host interface on port 80 using the -p
flag.
sudo docker run -p 80:80 -i -t < old-image-id >
In my production environment I want to switch now from the old_container
to a new_container
. So I want to shut down the old_container
and start the new_container
.
First I have to do some manual changes in the new_container
. So I run it without the -p
flag, as I cannot bind it to port 80 before I have done this changes.
sudo docker run -i -t < new-image-id >
#now I m doing my manual changes
When I'm finished with my changes I logout of the new_container
. My plan was now to stop the old_container
and bind the new_container
to port 80. But the [start][1]
command does not provide a port binding possibility.
So to come to my question: I'm looking to set the port binding for a stopped container, preferably without the workaround of creating a commit image of the new_container
and running this image as another new container.
docker stop old_container new_container
docker commit new_container new_container_01
docker run -p 80:80 -i -t new_container_01
docker rm old_container new_container
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With