Update apt
and install packages to allow apt
to use a repository over HTTPS
$ sudo apt-get update
$ sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
Add GPG key
$ sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Set up Docker repository
$ echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker engine
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
Run the Hello-World
image to verify the installation
$ sudo groupadd docker
$ sudo usermod -a -G docker ${USER}
$ newgrp docker
$ su -s ${USER}
This command is optional (In case if you run docker without adding the user first)
$ sudo chown "$USER":"$USER" /home/"$USER"/.docker -R
$ sudo chmod g+rwx "$HOME/.docker" -R
$ sudo service docker start
$ sudo docker run hello-world
This command downloads a test image and runs it in a container.
Be the first to comment on "Installing docker on ubuntu"