====== Systems - Docker Main - Install Docker ======
===== Install Dependencies =====
Install dependencies necessary to add a new HTTPS repository.
sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
----
===== Import the Docker GPG Key =====
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
----
===== Add the Docker apt Repository =====
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
----
===== Install Docker =====
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io
**NOTE:** This will install the latest version of Docker.
* The Docker service will start automatically after the install.
* To install a specific version of Docker, list available versions:
sudo apt update
apt list -a docker-ce
* and install with:
sudo apt install docker-ce= docker-ce-cli= containerd.io
**NOTE:** Docker will be automatically updated through standard:
sudo apt update
sudo apt upgrade
* To prevent the Docker package from being updated, mark it as held back:
sudo apt-mark hold docker-ce
----
===== Check the Docker Status =====
sudo systemctl status docker
----
===== Set Permissions =====
Non-Root User
sudo usermod -aG docker $USER
**NOTE:** By default, only root and user with sudo privileges can execute Docker commands.
* **$USER** is an environment variable that holds the logged in username.
* Log out and log back in so that the group membership is refreshed.
----
===== Verifying the Docker Installation =====
docker container run hello-world
**NOTE:** This should display **Hello from Docker**.