Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Install Docker on Ubuntu
coder7475
coder7475

Posted on

     

Install Docker on Ubuntu

Before installing Docker Engine on a new Ubuntu host machine, you need to set up the Dockerapt repository. Once the repository is configured, you can install and update Docker directly from it.


1.Set up Docker'sapt repository

Follow these steps to configure the repository:

# Update package index and install prerequisites:sudoapt-get updatesudoapt-getinstall-y ca-certificates curl# Create a directory for Docker's GPG key:sudo install-m 0755-d /etc/apt/keyrings# Download Docker's official GPG key:sudocurl-fsSL https://download.docker.com/linux/ubuntu/gpg-o /etc/apt/keyrings/docker.ascsudo chmoda+r /etc/apt/keyrings/docker.asc# Add Docker's repository to Apt sources:echo\"deb [arch=$(dpkg--print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu\$(. /etc/os-release&&echo"${UBUNTU_CODENAME:-$VERSION_CODENAME}") stable" |\sudo tee /etc/apt/sources.list.d/docker.list> /dev/null# Update the package index again:sudoapt-get update
Enter fullscreen modeExit fullscreen mode

2.Install Docker packages

Install the latest version of Docker Engine and its components:

sudoapt-getinstall-y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Enter fullscreen modeExit fullscreen mode

3.Check Docker and containerd status

Verify that Docker and containerd services are running:

sudosystemctl status containerdsudosystemctl status docker
Enter fullscreen modeExit fullscreen mode

If either service is inactive, start them using:

sudosystemctl start containerdsudosystemctl start docker
Enter fullscreen modeExit fullscreen mode

4.Verify the installation

Run thehello-world image to confirm Docker is working correctly:

sudodocker run hello-world
Enter fullscreen modeExit fullscreen mode

This command downloads a test image, runs it in a container, and prints a confirmation message.


5.Run Docker withoutsudo

To avoid usingsudo with every Docker command, add your user to the Docker group:

sudousermod-aG docker$USERnewgrp docker
Enter fullscreen modeExit fullscreen mode

6.Final verification

Run thehello-world image again, this time withoutsudo:

docker run hello-world
Enter fullscreen modeExit fullscreen mode

If successful, you have installed and configured Docker Engine on your Ubuntu machine.


References

  1. Docker Documentation
  2. Docker Installation Challenge

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

I am a Software Engineer focusing on web development. I am currently exploring the world of DevOps Engineering.
  • Joined

More fromcoder7475

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp