Installing Docker on Ubuntu 22.04
This guide will walk you through the steps to install Docker on an Ubuntu 22.04 server, including setting up the firewall and OpenSSL.
Step 1: Update and Upgrade the System
First, update and upgrade your system packages to ensure you have the latest versions.
sudo apt update && sudo apt upgrade -yStep 2: Install Required Packages
Install the necessary packages for Docker and OpenSSL.
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
sudo apt install openssl -yStep 3: Add Docker’s Official GPG Key
Add Docker's official GPG key to your system.
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpgStep 4: Set Up the Docker Repository
Add the Docker repository to APT sources.
echo "deb [arch=amd64 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/nullStep 5: Install Docker
Update the package database with the Docker packages from the newly added repo and install Docker.
sudo apt update
sudo apt install docker-ce -yStep 6: Verify Docker Installation
Check the Docker version to verify the installation.
docker --versionStep 7: Start and Enable Docker
sudo systemctl status dockerStep 7: Manage Docker as a Non-root User
Add your user to the docker group to manage Docker as a non-root user.
sudo usermod -aG docker ${USER}Log out and log back in so that the group membership is re-evaluated.
Step 8: Set Up the Firewall
Install ufw (Uncomplicated Firewall) and allow necessary ports.
sudo apt install ufw -y
sudo ufw allow OpenSSH
sudo ufw enableTo allow Docker to manage its own firewall rules, disable ufw's interaction with Docker.
sudo nano /etc/ufw/ufw.confSet MANAGE_BUILTINS=no in the configuration file.
Step 9: Install OpenSSL
OpenSSL should already be installed from Step 2, but you can verify it with:
openssl versionConclusion
You have successfully installed Docker on your Ubuntu 22.04 server, set up the firewall, and installed OpenSSL. You can now start using Docker to manage your containers.