Installing Docker Environment on Linux Ubuntu Server

After remotely accessing the Linux server, use the following commands to install Docker.

sudo apt-get update  # Update the system
# Add dependencies sudo apt-get install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings  # Create a keyrings directory
# Add Docker's official GPG key curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
# Update the system and install Docker engine sudo apt-get update sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
# Verify Docker installation success docker version
# Pull a hello world image for testing docker run --rm hello-world

When using in China, it is necessary to configure the mirror for faster access. After Docker is installed, use the following command to configure the mirror source. Currently available mirror sources include:

# Free mirror source https://docker.xuanyuan.me/     Xuanyuan mirror source # Alibaba Cloud mirror source Apply for a personal exclusive mirror source in the Alibaba Cloud console, provided that you must have an Alibaba Cloud ECS server. If not, you can use the Xuanyuan mirror above.
# Write content in daemon.json (configure mirror source) sudo mkdir -p /etc/docker  sudo tee /etc/docker/daemon.json <<-'EOF'  {  "registry-mirrors": ["https://your-exclusive-ID.mirror.aliyuncs.com"]} EOF

Leave a Comment