Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
在 ubuntu 安装 docker
#!/bin/bash
# step 1: 安装必要的一些系统工具
apt-get update
apt-get install -y \
ca-certificates \
curl \
gnupg \
lsb-release
# step 2: 安装GPG证书
mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /etc/apt/keyrings/docker.gpg
chmod a+r /etc/apt/keyrings/docker.gpg
# Step 3: 写入软件源信息
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
# Step 4: 更新并安装 Docker-CE
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io docker-compose-plugin
# 5. 启动
service docker start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment