Docker Toolbox Compose



Scaling each service is done using Docker Compose, for example type docker-compose scale test-app=4 to have 4 instances of application “test” running. Those instances will be automatically load-balanced by the gateway(s), and will automatically join the same Hazelcast cluster (if Hazelcast is your Hibernate 2nd-level cache). Install using Docker Compose. Use this information to quickly start up Community Edition using Docker Compose. Note: While Docker Compose is often used for production deployments, the Docker Compose file provided here is recommended for development and test environments only.

  • Docker Tutorial
  • Docker Useful Resources
  • Selected Reading

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.

Docker Compose ─ Installation

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.

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 −

Docker Toolbox Compose Command

  • 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.

And when you do a docker ps, you can see that the containers are indeed up and running.

  • Docker Tutorial
  • Docker Useful Resources
  • Selected Reading

Docker Toolbox Compose Version


In the introductory chapters, we have seen the installation of Docker toolbox on Windows. The Docker toolbox is developed so that Docker containers can be run on Windows and MacOS. The site for toolbox on Windows is https://docs.docker.com/docker-for-windows/

For Windows, you need to have Windows 10 or Windows Server 2016 with Hyper-V enabled.

The toolbox consists of the following components −

  • Docker Engine − This is used as the base engine or Docker daemon that is used to run Docker containers.

  • Docker Machine − for running Docker machine commands.

  • Docker Compose for running Docker compose commands.

  • Kinematic − This is the Docker GUI built for Windows and Mac OS.

  • Oracle virtualbox

Let’s now discuss the different types of activities that are possible with Docker toolbox.

Running in Powershell

With Docker toolbox on Windows 10, you can now run Docker commands off powershell. If you open powershell on Windows and type in the command of Docker version, you will get all the required details about the Docker version installed.

Pulling Images and Running Containers

You can also now pull Images from Docker Hub and run containers in powershell as you would do in Linux. The following example will show in brief the downloading of the Ubuntu image and running of the container off the image.

The first step is to use the Docker pull command to pull the Ubuntu image from Docker Hub.

The next step is to run the Docker image using the following run command −

You will notice that the command is the same as it was in Linux.

Kitematic

This is the GUI equivalent of Docker on Windows. To open this GUI, go to the taskbar and on the Docker icon, right-click and choose to open Kitematic.

It will prompt you to download Kitematic GUI. Once downloaded, just unzip the contents. There will be a file called Kitematic.exe. Double-click this exe file to open the GUI interface.

You will then be requested to log into Docker Hub, enter through the GUI. Just enter the required username and password and then click the Login button.

Once logged in, you will be able to see all the images downloaded on the system on the left-hand side of the interface.

On the right-hand side, you will find all the images available on Docker Hub.

Docker

Let’s take an example to understand how to download the Node image from Docker Hub using Kitematic.

Step 1 − Enter the keyword of node in the search criteria.

Docker

Step 2 − Click the create button on official Node image. You will then see the image being downloaded.

Once the image has been downloaded, it will then start running the Node container.

Step 3 − If you go to the settings tab, you can drill-down to further settings options, as shown below.

  • General settings − In this tab, you can name the container, change the path settings, and delete the container.

  • Ports − Here you can see the different port mappings. If you want, you can create your own port mappings.

Docker Toolbox Compose Commands

  • Volumes − Here you can see the different volume mappings.

Docker Toolbox Compose Commands

  • Advanced − It contains the advanced settings for the container.