In this post I'll try to explain the method I use to avoid having permission issues when using Docker Volumes. This is pre Docker 1.10 (which added user namespaces) and I will talk about those in my next post.
Before we begin let me explain what are Docker Volumes and what they're used for. The official Docker docs explain this feature as follows:
A data volume is a specially-designated directory within one or more containers that bypasses the Union File System.
The main use-case for volumes is for persisting data between container runs (seeing as container are ephemeral). This is useful for data directories when running databases (such as PostgreSQL) within containers. Other than persisting databases it's useful for sharing code folders from your host system to the container when running in your development environment.