How do I start a Docker container with a volume?

0 votes
Jul 2 in Docker by Sirajul
• 5,960 points
22 views

1 answer to this question.

0 votes

You can first create the volume and then start the container or .If you are trying to start a container with a volume that doesn't exist, docker will create a volume for you. Suppose you want to mount a volume (say vol1) into /app/ of the container (say mycontainer1).

You can do this either by using -v or --mount. Here's how you can do it.

$ docker run -d \
  --name mycontainer1 \
  --mount source=vol1,target=/app \
  ubuntu:latest

You can achieve the same using -v instead of --mount as shown below:

$ docker run -d \
  --name mycontainer1 \
  -v vol1:/app \
  ubuntu:latest

Either of these would do!

answered Jul 2 by Namik
• 800 points

Related Questions In Docker

0 votes
1 answer

How to base a docker volume with docker container?

Run the following command: docker run -d --volumes-from ...READ MORE

answered Aug 5, 2018 in Docker by Sophie may
• 9,430 points
64 views
0 votes
1 answer

How do I get into a Docker container?

docker attach will let you connect to your ...READ MORE

answered Aug 10, 2018 in Docker by Kalgi
• 37,320 points
45 views
0 votes
1 answer

How do I copy a file from docker container to host?

Here is a way which you can ...READ MORE

answered Aug 27, 2018 in Docker by Damon Salvatore
• 5,490 points
1,458 views
0 votes
1 answer

How do I run a docker image as a container?

You can run an image depends on whether you ...READ MORE

answered Sep 7, 2018 in Docker by Damon Salvatore
• 5,490 points
56 views
+1 vote
1 answer
0 votes
1 answer

What is a docker file? How do I create a docker image with dockerfile?

 A Dockerfile is a script/text configuration file that contains ...READ MORE

answered Jun 7 in Docker by Sirajul
• 5,960 points
249 views
0 votes
1 answer
+2 votes
11 answers
0 votes
2 answers

How to edit file after I shell to a docker container?

You can even install it using a ...READ MORE

answered Apr 23 in Docker by Ashish
2,225 views