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

0 votes
How do I start a container and create a volume using a volume driver? Can I have a line command for it?
Jul 24, 2019 in Docker by Umer
1,546 views

2 answers to this question.

0 votes

Hey @Umer, you can use something like this:

$ docker run -d \
  --name sshfs-container \
  --volume-driver vieux/sshfs \
  --mount src=sshvolume,target=/app,volume-opt=sshcmd=test@node2:/home/test,volume-opt=password=testpassword \
  nginx:latest
answered Jul 24, 2019 by Jinu
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 Aug 6, 2019 by Sirajul
• 59,230 points

Related Questions In Docker

+1 vote
1 answer
0 votes
1 answer

How do I start a Docker container with a volume?

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

answered Jul 2, 2019 in Docker by Namik
• 1,230 points
25,116 views
0 votes
1 answer

How do I create a service using an image from a private registry?

Hey @Ruby, If your image is available ...READ MORE

answered Jul 8, 2019 in Docker by Sirajul
• 59,230 points
1,002 views
+1 vote
1 answer

How do i install jenkins using a dockerfile on a windows container?

Here is to how you can install JENKINS ...READ MORE

answered Aug 22, 2019 in Docker by Sirajul
• 59,230 points
6,164 views
+2 votes
1 answer
+2 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 58,100 points
2,662 views
+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,414 views
0 votes
3 answers

How do I run Windows 7 in docker?

How To Install Docker on Windows 7/8/10 Home and Pro Get ...READ MORE

answered Aug 25, 2020 in Docker by Pistle
• 1,000 points
6,242 views
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