Docker Compose has gained lots of attention in the recent past due to its easy one-liner installation(on Linux, Windows & Mac OS X), easy-to-use JSON & YAML format support , available sample docker-compose files on GITHUB and a one-liner command to create and start all the services from your configuration. If you are looking out for Microservices implementation, Docker Compose is a great tool to get started with. With Compose, you can define and run complex application with Docker. Also, you define a multi-container application in a single file, then spin up your application in a single command which takes care of linking services together through Service Discovery.
Docker Compose 1.9 is currently under RC4 phase and nearing the Final Release. Several new features and improvements in terms of Networking, Logging & Compose CLI has been introduced. With this release, Docker Compose version 2.1 has been introduced for the first time.This release will support the setting up of volume labels and network labels in YAML specification. BUT there is a good news for Microsoft Windows enthusiasts. Interactive mode for docker-compose run
and docker-compose exec
is now supported on Windows platforms and this is surely going to help Microsoft enthusiasts to play around with the services flawlessly.
The below picture shows what major features has been introduced since last year in Docker Compose release:
In case you are very new to Docker Compose, I suggest you to read this official documentation. If you are an experienced Compose user and curious to know how Docker Compose fits into Swarm Mode, don’t miss out my recent blog post. Under this blog post, we will look at the new features which are being introduced under Docker Compose 1.9 release.
Installation of Docker Compose v1.9
On Windows Server 2016 system, you can run the below command to get started with Docker Compose 1.9-rc4 release.
If you are on Linux host, the installation just goes flawless as shown below:
# curl -L https://github.com/docker/compose/releases/download/1.9.0-rc3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose$ sudo docker-compose -vdocker-compose version 1.9.0-rc3, build fcd38d3
Introduction of Version 2.1 YAML specification format for the first time
Docker 1.9 introduces the newer version of Docker Compose YAML specification format rightly called “Version: 2.1” for the first time. To test drive, I created a docker-compose file for my wordpress application and it just worked well.
The docker-compose up -d just went good as shown below:
We can have a look at the list of services running using Docker compose as shown below:
Interactive Mode for docker exec
& docker run
Though this feature has been there for Linux users quite for sometime, it has been newly introduced and supported on Windows Platform too. In case you are new to docker-compose run
command, here is the simplified way to demonstrate it.
On Linux Host:
Note: In case you are new to docker-compose config
command, it is a CLI tool which validates your Docker compose file.
Cool. One can use docker-compose run
command to target one service out of several services mentioned under docker-compose.yml file and interact with that particular service without any issue.
On Windows Host:
To quickly test this feature, I spun up Windows Server 2016 on Azure, installed Docker and Docker Compose and forked https://github.com/ajeetraina/Virtualization-Documentation repository which has collection of Windows Docker images. Though it was quite slow in the beginning, but once pulled bringing up services using Docker Compose was pretty quick.
NOTE: When running docker-compose, you will either need to explicitly reference the host port by adding the option “-H tcp://localhost:2375” to the end of this command (e.g. docker-compose -H “tcp://localhost:2375” or by setting your DOCKER_HOST environment variable to always use this port (e.g. $env:DOCKER_HOST=”tcp://localhost:2375”
As shown below, the services finally were up and running and one can easily check through docker-compose ps
command as shown below:
Let us test docker-compose run
feature now. I tried targeting the db service and running cmd command to see if it works well.
That’s really cool. Believe me, it was quite quick in bringing up command prompt.
Support for setting volume labels and network labels in docker-compose.yml
This is an important addition to Docker compose release. There has been several ask from Docker community user to bring up this feature and Docker team has done a great job in introducing it under this release.
If you look at the last few lines, the volume labels has been specified in the following format:
volumes:
volume_with_labels:
labels:
– “alpha=beta”
To verify if it rightly build up the container with the volume labels, one can issue the below command:
In the upcoming posts, I will be covering more features and bug fixes introduced under Docker Compose 1.9. Keep watching this space for further updates.
Comments are closed.