Introduction:
If you're attempting to install Docker on Ubuntu 18.04 Bionic Beaver, which is known for having installation issues, this comprehensive guide aims to address common errors you may encounter during the process. Our goal is to save you time searching for answers on StackOverflow by providing clear instructions. The guide is based on the official Docker documentation available at https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository.
Step 1: Updating Package Lists
To begin, run the following command to update your package lists using the "apt-get update" command:
sudo apt-get update
Note: If you encounter any errors during the update process, it may be due to the older Ubuntu 18.04 release. In such cases, you can refer to the Configure DNS server IP to resolve errors with apt-get update guide for assistance. This guide will help you address any DNS-related issues that might be preventing successful updates.
Step 2: Installing Dependencies
Next, we need to install the necessary dependencies mentioned in the Docker article. These dependencies are required for Docker to function properly. Run the following command to install them:
sudo apt-get install ca-certificates curl gnupg lsb-release
This command may take some time to complete, as it downloads and installs the required dependencies. Please be patient and ensure that there are no errors.
Step 3: Adding Docker's Official GPG Key
To ensure the authenticity of Docker packages, we need to add Docker's official GPG key. This key will be used to verify the integrity of the downloaded packages. Execute the following command:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
This command downloads Docker's GPG key and saves it in the specified keyring file.
Step 4: Adding Docker's Repository
Now, let's add Docker's repository (PPA) to our apt sources. This repository will provide the Docker packages for installation. Run the following command:
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
Here, we're adding the Docker repository URL and configuration to the apt sources. This ensures that Docker packages can be fetched and installed from the appropriate source.
At this point, we have successfully completed the initial steps.
Step 5: Updating Package Lists Again
After adding the new Docker repository to our apt sources, it's necessary to update the package lists once more. Run the following command:
sudo apt-get update
This command retrieves the updated package information from the added repository.
Step 6: Installing Docker and Its Components
Now, we can proceed with installing Docker and its main components using the following command:
sudo apt-get install docker-ce docker-ce-cli containerd.io
Note: You may encounter the following famous error during this step:
"containerd.io: Depends: libseccomp2 (>= 2.4.0) but 2.3.1-2.1ubuntu4 is to be installed"
This error occurs because Ubuntu's apt sources cannot find a version of libseccomp2 higher than 2.3.1, while Docker requires version 2.4 or above.
To fix this error, we will add another source URL to our sources file, which contains the compatible libseccomp2 package for Ubuntu 18.04. Please follow the steps below.
Step 7: Creating a Backup of apt Sources (Optional)
For cautious administrators, it's recommended to create a backup of the apt sources before proceeding. You can use the following command to create a backup:
sudo cp /etc/apt/sources.list /etc/apt/bkup_20210104_sources.list_bkup
This command creates a backup copy of the apt sources file, providing a restore point if needed.
You can also verify the current source URLs on your server by running the following command:
grep -v '#' /etc/apt/sources.list
This command displays the source URLs without any commented lines.
Step 8: Editing the sources.list File
Now, let's edit the sources.list file to add the required source URL. Execute the following commands:
sudo -s
echo -e "deb http://security.ubuntu.com/ubuntu xenial-security main" >> /etc/apt/sources.list
exit
In this step, we're modifying the sources.list file to include an additional source URL. This URL contains the compatible libseccomp2 package for Ubuntu 18.04.
You can check if the new source URL was added successfully by running the command below:
grep -v '#' /etc/apt/sources.list
This command displays the updated source URLs, including the one we just added.
Step 9: Updating Package Lists Once Again
After updating the apt source file, it's essential to run the following command to update the repository:
sudo apt-get update
This command fetches the package information from the newly added source URL.
Step 10: Retry the Failed Docker Installation Step
Now, you can retry the previous failed Docker installation step, and it should proceed without any issues. Cheers!
To ensure that Docker Engine is installed correctly, you can verify it by running the hello-world image using the command provided below. Alternatively, you can refer to the main Docker instruction manual at https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository.
If you encounter any further errors during the installation process, please don't hesitate to reach out. I'm here to help and provide solutions to the best of my ability.
Cheers, and see you in another wonderful Linux/System Admin episode!
Comments
Post a Comment