Installing Docker on Ubuntu
Before we can use containers, we need to install Docker on our Ubuntu server which will manage them.
To put it simply: Docker is the container manager, what Hyper-V or VMware is to virtualization.
In addition to Docker, we will install docker-compose, which allows you to configure docker containers with files in yml format.
For this tutorial, I will be basing myself on the official Docker documentation.
Install Docker engine
This first command line is optional, we will first uninstall Docker if it is present, especially if you have installed the cockpit-docker module.
Install, the prerequisites for Docker:
Install the deposit key:
Add repository
Update the list of packages:
sudo apt update
We can see that the Docker repository has been added
Install Docker:
If at the end of the installation you get an error: Errors were encountered while processing: docker-ce. Restart the installation of the package.
Test that Docker is working properly using the command:
sudo systemctl status docker
Install Docker Compose
This part is optional, as I explained to you earlier Docker Compose allows you to configure containers using a file in yml format.
Download Docker Compose:
Make Docker Compose executable:
Test that it is working correctly using the following command:
Testing Docker with Hello World
We will now test our Docker installation by deploying our first Hello World container.
This container does nothing in particular, but it will allow us to ensure the proper functioning of our service.
Enter the command below to launch the hello-world container:
sudo docker run hello-world
If you get the Hello from Docker! It’s all good, congratulations, you have deployed your first container.
Enter the following command to display the containers on the server and their status:
sudo docker ps -a
We can see the hello-world container.
In Cockpit, we can also see our container.
To display “off” containers select Everything at the top.
Docker is now installed and functional on the server, we will be able to move on to container deployment, before launching into container installation, I will give you some useful information before going further.