Avoiding common pitfalls
Till now, we 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, we learnt that the Docker engine automatically creates directories based on the VOLUME
instruction in Dockerfile
as well as the -v
option of the docker run
subcommand. We also understood that the Docker engine does not automatically delete these auto-generated 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 docker rm...