Docker Compose
Last updated
Was this helpful?
Last updated
Was this helpful?
Please read our disclaimer .
You can find our docker-compose templates here, feel free to contribute!
Using Compose is basically a three-step process:
Define your app’s environment with a
Dockerfile
so it can be reproduced anywhere.Define the services that make up your app in
docker-compose.yml
so they can be run together in an isolated environment.
Always worth checking the official docs:
You can run the following command to install docker compose v1 (where you have to run the command with docker-compose up -d
)
Or the following command for v2 (where you have to run the command with docker compose up -d
)
Docker compose can be run with variable set in an .env
file. If this file is in the same directory as the compose file, it will pick this up automatically.
PLEASE NOTE
With these examples, we have labels for Traefik. if you do not use Traefik, you can simply remove the whole labels section.
An example of a docker-compose.yml
file:
Example of a .env
file
Example how you can combine apps you want to run together and rely on each other to run. You can add a “depends_on
” variable which will not run the container until the others are already running.
You can also separate services on their own secure network and only give access to the apps that require it (example below has Redis and MariaDB on a secure, separated network).
Linked .env
file example
.env
file to match
.env
file to match
A trick you can do with the .env file is you can just create one file, with all your values, then hardlink it to each directory where your docker compose files are. This means you only have to add the variables once, to one file, and if you change it, it changes everywhere. You can hardlink the global .env file with the following command:
Then simply run the docker compose run command to start the container (remember to run these commands from within the folder where the compose file is):
Pulling the latest version of an app is easy, simply pull the latest image and then restart the app (remember to run these commands from within the folder where the compose file is):
Our Discord community our Community Leaders oldcrazyeye, DiscDuck and Sycotix for their input and documentation.
We hope you enjoyed this guide. It was conceptualized, written, and implemented by our Community Leader Hawks.
Our work sometimes takes months to research and develop. If you want to help support us please consider:
Thank you for choosing to collaborate with
Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration. To learn more about all the features of Compose, see .
Compose works in all environments: production, staging, development, testing, as well as CI workflows. You can learn more about each case in .
Run docker compose up
and the starts and runs your entire app. You can alternatively run docker-compose up
using the docker-compose binary.
Source:
Install -
Useful Information -
If you followed the commands to install docker here for Ubuntu for example -
Please support the developers and creators involved in this work to help show them some love.
Liking and Subscribing to our
Joining our
Becoming a paid member on our
Donating via