Easy Docker-Compose Installation On Ubuntu
This guide walks you through installing Docker on Ubuntu 24.04 (Noble Cloud) using a simple script. Docker is a powerful tool for containerizing applications, and this script automates the setup process for you.
What Does the Script Do?
The script:
- Updates your system’s package list.
- Installs prerequisites like
curl
andgnupg
. - Downloads Docker’s GPG key and sets up a secure keyring.
- Adds Docker’s official repository to your system.
- Installs Docker and its related tools.
- Verifies the installation by checking Docker and Docker Compose versions.
Prerequisites
Before you start, ensure:
- You have an Ubuntu 24.04 machine.
- You have
sudo
privileges.
Step-by-Step Guide
Step 1: Create the Script File
- Open a terminal.
- Create a new file named
install_docker.sh
:1
nano install_docker.sh
- Paste the following script into the file: Github
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
#!/bin/bash # Make the script executable: chmod +x install_docker.sh # Run the script: ./install_docker.sh # Update package lists and install prerequisites sudo apt-get update sudo apt-get install -y ca-certificates curl gnupg # Create the keyring directory sudo install -m 0755 -d /etc/apt/keyrings # Download and add Docker's GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg sudo chmod a+r /etc/apt/keyrings/docker.gpg # Add the Docker repository to apt sources echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo $VERSION_CODENAME) stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null # Update package lists again sudo apt-get update # Install Docker and related components sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin # Check Docker version docker -v # Check Docker Compose version docker compose version
Save the file (Ctrl + O, then Enter) and exit (Ctrl + X).
- Start the script
1
./install_docker.sh
Congratulations!
You’ve successfully installed Docker on Ubuntu 24.04 using the script. Docker is now ready to help you build, ship, and run containers.
If you encounter any issues, feel free to ask for help. 🚀
This post is licensed under CC BY 4.0 by the author.