...

/

Using Volumes With Containers

Using Volumes With Containers

Let's see how to use volumes with containers.

Creating a container with a volume

Run the following command to create a new standalone container called voltainer that mounts a volume called bizvol.

$ docker run -it --name voltainer \
--mount source=bizvol,target=/vol \
alpine
Creating and Running a container with a volume

The command specified the --mount flag, telling Docker to mount a volume called bizvol into the container at /vol. The command completed successfully even though you didn’t have a volume called bizvol. This raises an important point:

  • If you specify a volume that already exists, Docker will use it

  • If you specify a volume that does not ...