How To Install Docker on Ubuntu 22.04 LTS
Installing Docker on Ubuntu 22.04 LTS
Requirements
- A running instance of Ubuntu 22.04 LTS.
- A user account with sudo privileges.
Steps to Install Docker
- Update Your System:
- Open a terminal and update the package index:
sudo apt update sudo apt upgrade -y
- Open a terminal and update the package index:
- Install Required Packages:
- Install packages to allow apt to use a repository over HTTPS:
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
- Install packages to allow apt to use a repository over HTTPS:
- Add Docker’s Official GPG Key:
- Add the GPG key for the Docker repository:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Add the GPG key for the Docker repository:
- Add the Docker Repository:
- Add the Docker repository to APT sources:
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Add the Docker repository to APT sources:
- Update the Package Index Again:
- Refresh the package index to include the new Docker repository:
sudo apt update
- Refresh the package index to include the new Docker repository:
- Install Docker:
- Install the latest version of Docker CE (Community Edition):
sudo apt install docker-ce -y
- Install the latest version of Docker CE (Community Edition):
- Start and Enable Docker:
- Start the Docker service and enable it to run on startup:
sudo systemctl start docker sudo systemctl enable docker
- Start the Docker service and enable it to run on startup:
- Verify Docker Installation:
- Check if Docker is installed correctly by running:
sudo docker --version - You can also run the hello-world image to test Docker:
sudo docker run hello-world
- Check if Docker is installed correctly by running:
- Manage Docker as a Non-root User (Optional):
- To run Docker commands without
sudo, add your user to the Docker group:sudo usermod -aG docker $USER - Log out and back in for the changes to take effect.
- To run Docker commands without
- Check Docker Status:
- Verify that Docker is running:
sudo systemctl status docker
- Verify that Docker is running:
Conclusion
You have successfully installed Docker on Ubuntu 22.04 LTS. You can now start using Docker to manage containers and images.