Tag: Volumes

Volumes with Docker are a popular topic, particularly on the forums and Q&A sites I watch. From there I’ve seen confusion because of the multiple ways to create a volume. From these interactions, I’ve come away with a best practice of my own:
Don’t Create Volumes Inside a Dockerfile When creating an image, specifying your volumes in the image seems like a basic step that better defines how your image should be used.

This is the last in a 3 part series covering all the changes in the Docker 1.12 release. Part 1 covered changes introduced to building images, distribution, and logging. And part 2 covered changes introduced to networking, the new plugin interface, and the client API. This post will cover changes to the runtime, swarm, volumes, and deprecated features.
Runtime The runtime gets to the core of Docker, with changes made to components like storage drivers, the engine restart behavior, events, systemd integration, namespaces, and container specific kernel settings.

If you’ve tried to mount a volume with your services in Docker’s new swarm, you’ve likely hit at least one road block, the primary one being the lack of a -v option:
$ docker service create --name nginx \ -v /mysite:/usr/share/nginx/html -p 80:80 nginx unknown shorthand flag: 'v' in -v See 'docker service create --help'. The solution to this comes in the form of --mount but it has a completely different syntax than volume mounts.

There are more than several informative blog posts and articles that explain Docker data management to great length, however confusion has recently been introduced with the introduction of the volume API in Docker 1.9. Managing persistent data within your containerized environment should not be difficult – thankfully with a little information, it’s not! There are recommended ways however to do it better that might set you up for less headache in the future.