Docker is a popular platform for developing, shipping, and running applications in containers. It simplifies application deployment and management by providing a consistent and isolated environment for your applications. If you're using a DigitalOcean droplet running Ubuntu, you can easily install Docker to take advantage of its containerization capabilities. In this tutorial, we will walk you through the process of installing Docker on your Ubuntu-based DigitalOcean droplet.
Prerequisites
Before you begin, make sure you have the following prerequisites:
- A DigitalOcean account with a running Ubuntu droplet.
- SSH access to your droplet.
Step 1: Update Package Repository
Start by connecting to your DigitalOcean droplet via SSH. You can use your favorite SSH client or the DigitalOcean web console. Once connected, it's a good practice to update the package repository to ensure you have the latest package information.
sudo apt update
Step 2: Install Required Dependencies
Docker requires some dependencies to be installed on your system. Run the following command to install them. Following sets apt to use HTTPS for package installations:
sudo apt install apt-transport-https ca-certificates curl software-properties-common
Add docker repository PGP key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
Add docker repository to apt:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Force apt to use docker repository instead of ubuntu:
apt-cache policy docker-ce
sudo apt update -y
Step 3: Install Docker
Now that you've added the Docker repository, you can install the Docker Engine:
sudo apt install docker-ce
Check if docker is running
sudo systemctl status docker
The CLI should output something similar to folllowing:
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; preset: enabled)
Active: active (running) since Wed 2023-11-08 06:55:37 UTC; 1h 1min ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 112025 (dockerd)
Tasks: 9
Memory: 34.8M
CPU: 920ms
CGroup: /system.slice/docker.service
└─112025 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Nov 08 06:55:36 www-1 systemd[1]: Starting docker.service - Docker Application Container Engine…
Nov 08 06:55:36 www-1 dockerd[112025]: time="2023-11-08T06:55:36.533836789Z" level=info msg="Starting up"
Nov 08 06:55:36 www-1 dockerd[112025]: time="2023-11-08T06:55:36.536201581Z" level=info msg="detected 127.0.0.53 nameserver, assuming systemd-res>
Nov 08 06:55:36 www-1 dockerd[112025]: time="2023-11-08T06:55:36.810702196Z" level=info msg="Loading containers: start."
Nov 08 06:55:37 www-1 dockerd[112025]: time="2023-11-08T06:55:37.289050489Z" level=info msg="Loading containers: done."
Nov 08 06:55:37 www-1 dockerd[112025]: time="2023-11-08T06:55:37.426648493Z" level=info msg="Docker daemon" commit=311b9ff graphdriver=overlay2 v>
lines 1-18
Press q to exit
Congratulations! You've successfully installed Docker on your Ubuntu-based DigitalOcean droplet. You can now start using Docker to containerize and manage your applications. If you need further assistance or want to explore more Docker features, consider referring to Docker's official documentation.
References:
How To Install and Use Docker on Ubuntu 20.04, by Brian Hogan
Note: Some of the text is generated by ChatGPT.