Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

Docker Tip #76: Where to Put Docker Compose Projects on a Server?


So, you're thinking about deploying a Docker Compose project, but where does the docker-compose.yml file go on your file system?

Let’s say you have 1 or more Docker Compose projects that you plan to run on a VPS such as DigitalOcean, but really it could be anywhere.

There’s a lot of options. Should it go in /opt, /var/www, /srv, ~/ or somewhere else?

The answer is, it depends. This is really a Linux distribution specific question. For example I prefer using Ubuntu and Debian in production, and according to Debian’s Filesystem Hierarchy Standard (FHS), one reasonable place for it to go would be in the /srv folder.

So if you had a project called todolist, you would end up with /srv/todolist and inside of there you could have your docker-compose.yml, .env file and even your application’s source code depending on how you plan to deploy it.

I like this strategy because it keeps things together and well organized. I would also put non-Dockerized projects in the /srv folder too because there’s nothing Docker specific about this decision. When in doubt, always think about what you would do without Docker first.

Free Intro to Docker Email Course

Over 5 days you'll get 1 email per day that includes video and text from the premium Dive Into Docker course. By the end of the 5 days you'll have hands on experience using Docker to serve a website.