Installing Docker and Docker Compose on Ubuntu 22.04
Docker and Docker Compose Installation on Ubuntu 22.04
Prerequisites
- A server running Ubuntu 22.04.
- A user account with
sudo
privileges.
Install Docker on Ubuntu 22.04
Step 1: Update Your System
Update your system’s package index.
sudo apt update
Step 2: Install Prerequisite Packages
Install packages to allow apt to use a repository over HTTPS.
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Step 3: Add Docker’s Official GPG Key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Step 4: Add the Docker Repository
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
Step 5: Install Docker CE
Update the package index with Docker packages from the new repo and install Docker CE.
sudo apt update
sudo apt install docker-ce
Step 6: Verify Docker Installation
sudo systemctl status docker
Install Docker Compose on Ubuntu 22.04
Step 1: Download Docker Compose
Download the latest version of Docker Compose. Replace
sudo curl -L "https://github.com/docker/compose/releases/download/<version>/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
Step 2: Apply Executable Permissions
sudo chmod +x /usr/local/bin/docker-compose
Step 3: Verify Docker Compose Installation
docker-compose --version
Post-Installation Steps
Add Your User to the Docker Group
To run Docker commands without sudo, add your user to the docker group.
sudo usermod -aG docker ${USER}
su - ${USER}
Conclusion
Docker and Docker Compose are now installed on your Ubuntu 22.04 server. You can begin using Docker to develop, deploy, and manage containers.