Docker Volumes are the mechanism for persiting data.
In thtis article, I would like to share basic knowledge about Docker volume.
Volumes have some advantages over bind mounts:
- Volumes are asier to back up
- You can easily manage values using Docker CLI commands
- Volumes can be more safely shared among multiple containers
- Volume’s contents exist outside the lifecycle of a given container
--mount flag for volume. We should use the
Consits of multiple key-value pairs, separated by commas and each consisting of a
||For named vlumes, this is the name of the volume. For anonymous vlumes, this field is omitted.|
||it takes as its value the path where the file or directory will be mouted in the container.|
||if present, causes the bind mount to be mouted into the container as read-only.|
||it can be specified more than once, takes a key-value pair consisting of the option name and its value|
# Create a volume
If you start a container with a volume that does not yet exist, Docker creates the volume. The following example mounts the volume
/app/ in the contaienr.
# Start a container with a volume
docker inspect devtest to verify that the volume was created and mounted correctly. Look for the
docker run -d \
docker inspect devtest to verify that the bind mount was created correctly. Look for the
If you want a Docker container to connect to host machine, please use the follows
- Docker for Mac:
- Docker for Windows:
🖥 Recommended VPS Service
VULTR provides high performance cloud compute environment for you.
Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour).
In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!