Today I will show you how to install Docker in Linux Mint and Ubuntu. Docker is a very useful tool which every developer should know. Using Docker you can run many applications with special containers. They are beside your system. For instance you code in php and you need php in your system to run application. With Docker you can install and run many versions of php. Let’s start!
First of all we should update the package lists:
sudo apt-get update
Next we have to install dependencies:
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common
Perhaps you have installed all dependencies. After installing dependencies we have to add GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(. /etc/os-release; echo "$UBUNTU_CODENAME") stable"
When we add a new repository we have to remember to update package lists. So one more time we run sudo apt-get update .
Then we can install Docker in Linux Mint and Ubuntu (we install also docker-compose):
sudo apt-get install docker docker-compose
After installing Docker we have to add our user to a docker group:
sudo usermod -aG docker $USER
It is necessary in order to run Docker without root privileges (without sudo). In my opinion running Docker wit sudo is not a good idea. Remember restart machine after adding your user to group!
We can check our installation:
docker run hello world
You should see something similar to this:
If you will see it it means that your installation is correct.
I wrote a shell script which install Docker in Linux Mint and Ubuntu automatically:
You can get it on my GitHub.
You can see tutorial on YouTube.