Docker Compose is a tool for defining and running multi-containers Docker applications. It uses YAML files to configure application services, then with a single command using the definitions in the file to start these services based on the configurations. If you want to build an environment on Ubuntu to build Docker containers, you’ll want to install Docker as well as Docker Compose to make your job easier.
Add Docker Official Repository
Docker has two editions: The Enterprise Edition (EE) and the Community Edition (CE). For this tutorial, we’re going to be installing the community edition of Docker. If you always want to automatically get the latest version of Docker on Ubuntu, you must add its official repository to the Ubuntu system. To do that, run the commands below to install prerequisite packages. Next, run the commands below to download and install Docker’s official GPG key. The key is used to validate packages installed from Docker’s repository making sure they’re trusted. You should see an output shown below: Now that the official GPG key is installed, run the commands below to add its stable repository to Ubuntu. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. At this point, Docker’s official GPG and repository should be installed on Ubuntu. For those who currently have older versions of Docker, run the commands below to remove them. When you have removed all previous versions of Docker, run the commands below to install the latest and current stable version of Docker. To install a specific version of Docker, run the apt-cache command. Then select the version to install. Now to install a specific version, run the commands below with the version you wish to install If you just want to latest version without specifying the above, run the commands below. The command below will always install the highest possible version. That should install Docker software on Ubuntu. Verify that Docker CE is installed correctly by running the hello-world image, run the commands below: You should see a similar line below: Docker is installed correctly!
Install Docker Compose
On Ubuntu Linux, you can download the Docker Compose binary from the Compose repository release page on GitHub. To install it, run the commands below to download version 1.24.0. As of this writing, this was the current version. To install a different version of Compose, substitute 1.24.0 with the version of Compose you want to use. After downloading it, run the commands below to apply executable permissions to the binary file and create a symbolic link to /usr/binary That should get Docker Compose working. To test, run the commands below: You should see similar output as below: That’s it! To run Docker as a non-root user, add your user account to Docker’s group by running the commands below: Log out and back in, and you should be able to run docker with your standard account. Congratulations! You have learned how to install Docker and Docker Compose on Ubuntu 16.04 / 18.04 LTS systems. You may also like the post below: