0

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

1
  • 1
    Do you mean a new container with that parameters or the same container? Commented Apr 12, 2017 at 13:12

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

so this is the docker flow, this is what i need, thanks
1

No, you can only use docker run to start a new container. And of course, with another container name.

Comments

0
docker run --name nginx-base -p 80:80 -v mydomain:/etc/nginx/site-available/mydomain -d nginx

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.