Introduction
Docker is an application that makes it simple and easy to run application processes in a container, which are like virtual machines, only more portable, more resource-friendly, and more dependent on the host operating system.
Docker Compose is a tool for defining and running multi-container Docker applications. With Compose, you use a YAML file to configure your application’s services. Then, with a single command, you create and start all the services from your configuration
This article will explain how to install docker and docker-compose on Ubuntu 16.04. I use Ubuntu 16.04 on Google Cloud Compute Engine which has been deployed on the previous article.
Open your terminal or if you're using the compute engine VM instance, click the ssh button to open your terminal and run these commands :
1. Docker installation
Install curl
sudo apt-get install curl
Add repository key to package manager
curl --fail --silent --show-error --location https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Install manager for software repositories
sudo apt-get install software-properties-common
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get update
Check availability of the docker-ce package
apt-cache policy docker-ce
Should output something similar to:
docker-ce: Installed: (none) ...
Install the docker-ce package
sudo apt-get install -y docker-ce
Check Docker is running
sudo systemctl status docker
Add your user to the docker group
sudo usermod -aG docker ${USER}
Take the new group in use with
sudo su - ${USER}
2. Docker compose installation
sudo curl -L https://github.com/docker/compose/releases/download/1.18.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
Check Docker compose is installed
docker-compose --version