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 23 in Docker by Umer
28 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 23 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 by Sirajul
• 29,660 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 in Docker by Namik
• 1,200 points
95 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 in Docker by Sirajul
• 29,660 points
21 views
0 votes
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 in Docker by Sirajul
• 29,660 points
157 views
0 votes
1 answer
0 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
• 56,900 points
187 views
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
• 29,660 points
339 views
0 votes
2 answers

How do I run Windows 7 in docker?

By definition of the tool, docker cannot ...READ MORE

answered Aug 14 in Docker by Sirajul
• 29,660 points
80 views