How do I start a Docker container with a volume

0 votes
Jul 2, 2019 in Docker by Sirajul
• 59,230 points
25,318 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, 2019 by Namik
• 1,230 points

Related Questions In Docker

0 votes
2 answers

How do I start a container and create a volume using a volume driver?

You can first create the volume and ...READ MORE

answered Aug 6, 2019 in Docker by Sirajul
• 59,230 points
1,648 views
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
• 10,620 points
1,128 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
• 52,350 points
776 views
+1 vote
2 answers

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

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

answered Aug 28, 2018 in Docker by Damon Salvatore
• 5,980 points
28,576 views
+1 vote
2 answers

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,980 points
1,599 views
+1 vote
1 answer
+1 vote
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, 2019 in Docker by Sirajul
• 59,230 points
4,502 views
0 votes
1 answer

How can i start with DOCKER as a back-front end web dev?

Hi@aminegac, For running an application you need an ...READ MORE

answered Dec 4, 2020 in Docker by MD
• 95,460 points
934 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP