Avoiding common pitfalls
Until now, we have discussed how effectively data volumes can be used to share data between the Docker host and the containers as well as between containers. Data sharing using data volumes is turning out to be a very powerful and essential tool in the Docker paradigm. However, it does carry a few pitfalls that are to be carefully identified and eliminated. In this section, we make an attempt to list out a few common issues associated with data sharing and the ways and means to overcome them.
Directory leaks
Earlier in the Data volume section, you learned that the Docker Engine automatically creates directories based on the VOLUME
instruction in the Dockerfile
as well as the -v
option of the docker run
subcommand. We also understood that the Docker Engine does not automatically delete these autogenerated directories in order to preserve the state of the application(s) run inside the container. We can force Docker to remove these directories using the -v
option of the...