In this blog post, I will show you how to create a data volume on a Docker host running on Linux CentOS.
Create Volume
I will start by creating a volume using the following docker command.
docker volume create app
I called the volume app.
Deploy Container and Mount Volume
To run a container and attach the volume to it I will use the following command:
docker container run -it -v data:/app centos /bin/bash
Using the above command I mounted the volume into the app directory inside the container.
Any data that I save inside the app directory is kept on the container host after I delete the container.
This blog post was first published on our sister blog https://www.ntweekly.com
1 thought on “Create a Data Volume and Mount It on a Docker Container”
Comments are closed.