Fading Coder

One Final Commit for the Last Sprint

Home > Tech > Content

Installing Docker Engine on Linux Systems

Tech May 17 1

Quick Installation via Official Script

The fastest method to deploy Docker involves using the official convenience script. This approach handles repository setup and package installation automatically:

curl -fsSL https://get.docker.com | sh

To accelerate the download process in certain regions, specify a mirror:

curl -fsSL https://get.docker.com | sh -s -- --mirror Aliyun

Manual Installation on Ubuntu

For systems using the APT package manager, follow these steps to set up the Docker repository and install the engine.

First, prepare the system by updating the package index and installing prerequisite utilities:

sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg

Create a dedicated directory for the GPG key and import the Docker signing key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Configure the APT repository:

echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Refresh the package index and install Docker Engine along with the containerd runtime and plugins:

sudo apt-get update
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

To lock the installation to a specific release, list available versions:

apt-cache madison docker-ce

Then install using the version string:

sudo apt-get install -y docker-ce= docker-ce-cli= containerd.io

Manual Installation on CentOS

On RPM-based distributions, install the yum-utils package first to manage repositories:

sudo yum install -y yum-utils
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

Proceed with the Docker Engine installation:

sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Start and enable the Docker service:

sudo systemctl start docker
sudo systemctl enable docker

For specific version installations, query available packages:

yum list docker-ce --showduplicates | sort -r

Install the desired version:

sudo yum install -y docker-ce- docker-ce-cli- containerd.io

Verifying the Installation

Confirm that Docker Engine is installed correctly by checking the version:

docker --version

Run a test container to verify the daemon is functioning:

sudo docker run hello-world

Network Configuration

If containers require outbound network access, ensure IP forwarding is enabled:

# Edit /etc/sysctl.conf
net.ipv4.ip_forward = 1

# Apply changes
sudo sysctl -p

For container-to-container communication issues, adjust the iptables default policy:

sudo iptables -P FORWARD ACCEPT

BuildKit Compatibility

Newer Docker versions enable BuildKit by default, which may cause issues with HTTP-based registries. To disable this feature, set the following environment variable:

echo "export DOCKER_BUILDKIT=0" >> ~/.bashrc
source ~/.bashrc

When building images with caching issues, append the --no-cache flag to force a clean build:

docker build --no-cache -t myimage:latest .

Related Articles

Understanding Strong and Weak References in Java

Strong References Strong reference are the most prevalent type of object referencing in Java. When an object has a strong reference pointing to it, the garbage collector will not reclaim its memory. F...

Comprehensive Guide to SSTI Explained with Payload Bypass Techniques

Introduction Server-Side Template Injection (SSTI) is a vulnerability in web applications where user input is improper handled within the template engine and executed on the server. This exploit can r...

Implement Image Upload Functionality for Django Integrated TinyMCE Editor

Django’s Admin panel is highly user-friendly, and pairing it with TinyMCE, an effective rich text editor, simplifies content management significantly. Combining the two is particular useful for bloggi...

Leave a Comment

Anonymous

◎Feel free to join the discussion and share your thoughts.