Diving into docker compose files (
docker-compose.yml) there is a lot of keywords used. Some are obvious, others not. Here’s a little cheat sheet, not at all total coverage but hopefully a few nuggets to get started.
Build points to your Dockerfile. If it’s named Dockerfile and resides in the same directory as your
docker-compose.yml you can specify it with a dot (.) otherwise you can give it a path.
You can only use build OR image (se below) not both.
Names an image, local or remote (if its not local docker will try to pull it down). Could for example be redis, ubuntu, mongodb or something else.
This is used to set up relationships (links) between docker containers in your compose environment.
It’s also possible to set up aliases using the links.
Pretty self-explaining. What ports should be mapped out to the outside world. Follows a
So this example maps 80 to port 80, and port 8080 to a random port and interval 8000-8030 to 3000-3030.
Is used to mount paths as volumes. Can mount on the host machine or in the container.
Is used to mount volumes from another container or service. So and example could be a web server mounting volumes from a file server.
Specifies a custom name for the container.
Adds environment variables to the container. That in node.js for example can be accessed using process.env.
Next up I’ll look at the docker file.