Docker and Docker Compose Setup
Here’s a complete step-by-step guide to installing Docker and Docker Compose on Ubuntu 22.04
Step 1: Update the Package Index
Open your terminal and run the following command to update your package index:
Step 2: Install Required Packages
Install the necessary packages that allow apt
to use packages over HTTPS:
Step 3: Add Docker’s Official GPG Key
Download and add Docker’s GPG key using the recommended method:
Step 4: Add the Docker Repository
Add the Docker repository to your system:
Step 5: Update the Package Index Again
After adding the Docker repository, update the package index again:
Step 6: Install Docker
Now, install Docker:
Step 7: Start and Enable Docker
Start the Docker service and enable it to run on startup:
Step 8: Verify Docker Installation
Check if Docker is installed correctly by running:
You should see the installed version of Docker.
Step 9: Install Docker Compose
Download the Latest Version of Docker Compose:
Find the latest version from the Docker Compose GitHub releases page. As of now, you can use the following command (replace
v2.14.2
with the latest version if needed):Apply Executable Permissions:
Make the Docker Compose binary executable:
Verify Docker Compose Installation:
Check if Docker Compose is installed correctly by running:
You should see the installed version of Docker Compose.
Step 10: Manage Docker as a Non-root User (Optional)
If you want to run Docker commands without sudo
, you can add your user to the docker
group:
Add Your User to the Docker Group:
Replace
username
with your actual username if you're specifying it:Log Out and Back In:
Log out of your current session and back in to apply the group change. Alternatively, you can run:
Last updated