# Specify the set of containers that your app is composed of. # Specify the compose format that this file conforms to. Sample docker-compose.yml template version: '3.8' In this file, you define the application stack and the way components in the stack interact with each other. The default file name to use is docker-compose.yml, but you can specify a different name if you must by using the -f flag. The version statement should always be the very first line in the docker-compose.yml file. The docker-compose.yml file has several versions, with version 3 being the most current and recommended at the time of this writing. In the YAML file, you would specify several things. YAML stands for Yet Another Markup Language, and it is the format used for Docker Compose configuration files. The first part of Docker Compose is the YAML file. It works using two things, the Docker Compose YAML file, and The Docker Compose CLI. Docker Compose gives you a way to connect all the pieces of a solution together, along with setting up the networking and volumes, without having to run an excessive amount of commands at the command line. A Node container is going to need other containers like perhaps a Mongo container or a Redis container to do useful work. Containers are a single process, and most useful applications need much more than a single process to provide a useful service.
DOCKER YML FILE TUTORIAL SOFTWARE
Software services are not usually in isolation.
DOCKER YML FILE TUTORIAL HOW TO
In order to use Docker Compose, you’ll want to be familiar with building images, running containers, creating networks, and how to use volumes. Once your YAML file is complete, you can run a single command to bring up an application that may have multiple containers, a network, and one or more volumes as needed.ĭocker Compose is a combination of a command-line tool, working in concert with a configuration file(the YAML file mentioned above). By leveraging Docker Compose, you can define multi-container applications that provide a service, all by defining a single YAML File. This is where Docker Compose comes to the rescue. You may have noticed that when using the Docker command-line interface, the commands can be somewhat verbose and require a lot of memorization of what commands to run to accomplish all of the prior mentioned tasks.
At this point in our Docker Tutorial Series, we have learned how to get Docker installed, run some Nginx containers, tested out MongoDB in a container, spun up more than one container, learned about Docker networking, DNS, images, volumes, and much more.