DEV Community

Cover image for Straight-forward steps to installing docker on an Ubuntu machine
John Johnson Okah
John Johnson Okah

Posted on

2 2

Straight-forward steps to installing docker on an Ubuntu machine

Step 1: Uninstall Old Versions

sudo apt-get remove docker docker-engine http://docker.io containerd runc
Enter fullscreen mode Exit fullscreen mode

Step 2: Update apt package and install dependencies

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
 sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
Enter fullscreen mode Exit fullscreen mode

Step 3: Add Docker's official GPG key

sudo mkdir -p /etc/apt/keyrings
Enter fullscreen mode Exit fullscreen mode
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
Enter fullscreen mode Exit fullscreen mode

Step 4: Setup the 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
Enter fullscreen mode Exit fullscreen mode

Step 5: Install Docker Engine

sudo apt-get update
Enter fullscreen mode Exit fullscreen mode
sudo apt-get install docker-ce docker-ce-cli http://containerd.io docker-compose-plugin
Enter fullscreen mode Exit fullscreen mode

Step 6: Test the Installation

sudo service docker start
Enter fullscreen mode Exit fullscreen mode
sudo docker run hello-world
Enter fullscreen mode Exit fullscreen mode

Step 7: Add your user to the Docker group

sudo usermod -aG docker $USER
Enter fullscreen mode Exit fullscreen mode

PS: when you log out and back in, you should be able to run docker commands without sudo


Now Docker has been successfully installed on your Ubuntu system 🍻

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs