Reputation: 12684
I am able to run a container by running
docker run --name nginx-base -p 81:81 -d nginx
How do I use this same container but run it in port 80 and add a volume link to it such as:
docker start nginx-base -p 80:80 -v mydomain:/etc/nginx/site-available/mydomain
Upvotes: 0
Views: 91
Reputation: 12531
No, you can only use docker run
to start a new container. And of course, with another container name.
Upvotes: 1
Reputation: 32216
You can use the same image to launch another container on the port 80, with such a command
docker run --name nginx80 -p 80:80 -d nginx
as long as you use different ports and names for your container, you can go on, such as
docker run --name nginx83 -p 83:83 -d nginx
Consider that an image can't be updated (we will forget docker commit
), but the Dockerfile, the way to recreate an updated/modified image, helps you create easily another image.
The doc for docker commit
if needed
https://docs.docker.com/engine/reference/commandline/commit/
You can have a reference Dockerfile, so you build your image with such a command
docker build -t myuser/myproject:0.1 .
and a modified Dockerfile, such as Dockerfile_mod1, and you build another image using this Dockerfile, with a command such as
docker build -t myuser/mymodifiedproject:0.12 -f Dockerfile_mod1 .
but you should have a Dockerfile and rebuild as often as needed a modifed image.
Upvotes: 1
Reputation: 830
docker run --name nginx-base -p 80:80 -v mydomain:/etc/nginx/site-available/mydomain -d nginx
Upvotes: 0