Docker is a set of platform as a service products that use OS-level virtualization to deliver software in packages called containers. Containers are isolated from one another and bundle their own software, libraries and configuration files where they can communicate with each other through well-defined channels.
Here at Outsource Path, as part of our Server Management Services, we regularly help our Customers to perform Docker related tasks.
In this context, we shall look into the steps to Install Docker engine and Docker-Compose On Ubuntu.
To install Docker on Ubuntu, follow the step by step process provided below;
SSH or open the console on your Ubuntu server. Make sure you are logged in using an account with sudo privilege (admin) but not the main root account. Create a user with these privileges first and then login and follow this step.
Then Run the following command:
$ sudo apt-get update
Execute the command to install docker packages;
$ sudo apt-get install apt-transport-https ca-certificates gnupg-agent software-properties-common
When asked: Do you want to continue? [Y/n] Y
Type Y and hit enter to continue
This command downloads the Docker packages and prepares the installation on the Ubuntu server
To install docker gpg key, execute;
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
This will make sure that the public key provided is verified from Docker as the correct key. If it is genuine it will output the following simple message:
If you don't get OK, make sure the GPG key is from the correct link provided or if it has changed use the new URL.
Now set up the docker repository. To do so, execute;
sudo add-apt-repository deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable
This command adds the Docker repository to the Ubuntu system.
Then update the system by executing:
$ sudo apt-get update
Next, install docker engine;
$ sudo apt-get install docker-ce docker-ce-cli containerd.io
This will download and install the latest version of Docker to the Ubuntu system.
From the console terminal prompt run:
$ docker --version
You should see something similar:
Docker version 19.03.13, build 4484c46d9d
The version and build of the Docker engine will be displayed. If this is not satisfactory to your requirements, then install a specific engine version (Return to Step 5 and find the version you need from the Docker website).
Now test the engine by running a command:
$ docker run hello-world
This will run a container called hello-world. It should output:
Hello from Docker! This message shows that your installation appears to be working correctly.
Then, Use the following command to verify the process is running:
docker ps -a
You should see a container id and name list like the following:
In this step, download docker compose by running;
$ sudo curl -L https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
This downloads and prepares Docker-Compose on the system.
To do this, run;
$ sudo chmod +x /usr/local/bin/docker-compose
You need to set the executable or +x permission on the file
From the terminal prompt:
$ docker-compose --version
You should see the output:
docker-compose version 1.25.5, build 8a1c60f6