Docker software allows virtualization at the operating system level. Unlike VirtualBox and VMware Workstation, you run virtual applications as containers. Docker was developed by Docker Inc and runs software packages as containers which makes building applications that are easily shared and can run anywhere. 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.

How to add Docker repository on Ubuntu Linux

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!

How to install Docker Compose on Ubuntu Linux

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 should do 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. Conclusion: This post showed you how to install Docker and Docker Compose on Ubuntu Linux. If you find any error above or have something to add, please use the comment form below.