- Docker Tutorial
- Docker Useful Resources
- Selected Reading
Make COMPOSEDOCKERCLIBUILD=1 the default. Add usage metrics. Sync schema with COMPOSE specification. Improve failure report for missing mandatory environment variables. Bump attrs to 20.3.0. Bump moreitertools to 8.6.0. Bump cryptograhy to 3.2.1. Bump cffi to 1.14.4. Bump virtualenv to 20.2.2. Bump bcrypt to 3.2.0. Bump gitpython to 3.1.11. This will download Docker Container 1.24.0. (At the time this article was written, Docker Compose 1.24.0 is the latest version.) The –L option tells the system to follow any redirects, in case the file has been moved; If you want a different version of Docker Compose, you may browse the list and substitute your preferred version for /1.24.0/. Under Docker 19.03.0 Beta 2, support for NVIDIA GPU has been introduced in the form of new CLI API -gpus. Docker/cli#1714 talk about this enablement. Now one can simply pass -gpus option for GPU-accelerated Docker based application.
Docker Compose is used to run multiple containers as a single service. For example, suppose you had an application which required NGNIX and MySQL, you could create one file which would start both the containers as a service without the need to start each one separately.
In this chapter, we will see how to get started with Docker Compose. Then, we will look at how to get a simple service with MySQL and NGNIX up and running using Docker Compose.
The above command will download the latest version of Docker Compose which at the time of writing this article is 1.10.0-rc2. It will then store it in the directory /home/demo/. Step 2 − Next, we need to provide execute privileges to the downloaded Docker Compose file, using the following command −.
Docker Compose ─ Installation
Latest Version Of Docker Compose
The following steps need to be followed to get Docker Compose up and running.
Step 1 − Download the necessary files from github using the following command −
The above command will download the latest version of Docker Compose which at the time of writing this article is 1.10.0-rc2. It will then store it in the directory /home/demo/.
Step 2 − Next, we need to provide execute privileges to the downloaded Docker Compose file, using the following command −
We can then use the following command to see the compose version.
Syntax
Parameters
version − This is used to specify that we want the details of the version of Docker Compose.
Docker Compose Version Latest Version
Output
The version details of Docker Compose will be displayed.
Example
The following example shows how to get the docker-compose version.
Output
You will then get the following output −
Creating Your First Docker-Compose File
Now let’s go ahead and create our first Docker Compose file. All Docker Compose files are YAML files. You can create one using the vim editor. So execute the following command to create the compose file −
Let’s take a close look at the various details of this file −
The database and web keyword are used to define two separate services. One will be running our mysql database and the other will be our nginx web server.
The image keyword is used to specify the image from dockerhub for our mysql and nginx containers
For the database, we are using the ports keyword to mention the ports that need to be exposed for mysql.
And then, we also specify the environment variables for mysql which are required to run mysql.
Now let’s run our Docker Compose file using the following command −
This command will take the docker-compose.yml file in your local directory and start building the containers.
Once executed, all the images will start downloading and the containers will start automatically.
Docker Compose Latest Version
And when you do a docker ps, you can see that the containers are indeed up and running.