Docker installation

This guide is a resume of the lines exposed by the offical docker install for Ubuntu. If you got any problem you might refer to it looking for any change!

  
bash
sudo apt-get remove docker docker-engine docker.io containerd runc

sudo apt-get update

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

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 \
   $(lsb_release -cs) \
   stable"

sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io

At this point you must have access to docker as root user. We can verify it by runinng the following command.

  
bash
sudo docker run hello-world

It's a little bit hidden on the docker docs but most developers need to follow the docker's linux post installs intructions.

Non-root user docker install

The fist common task its to allow docker to be executed for non-root user in order to do that you could run the following commands:

  
bash
# !! WARNING: non-root user
sudo groupadd -f docker
sudo usermod -aG docker $USER
newgrp docker
docker run hello-world

Start docker on system boot

It's also usal to start the docker containers on system boot. If you want to achieve it you could enable it on systemd. You can read more about how to start containers automatically in the official documentation.

  
text
sudo systemctl enable docker

Docker-compose installation

Normally in your applications yo will a need multi-container application. For example if you need a redis, a php-fpm service and a mysql database you probably need docker compose. By defining a docker-compose.yml file you will have the hability to configure your application's services.

This guide is a resume of the lines exposed by the official install documentation. If you got any problem you might refer to it looking for any change!

With this simple two lines you will the latest stable version of docker compose and make it executable.

  
bash
sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose

Finally we test the installation by checking it with --version. You should have installed the latest docker-compose version.

  
bash
docker-compose --version
# docker-compose version X.XX.XX, build 8a1c60f6