docker

安装docker、docker-compose

ubuntu

卸载旧版本

apt-get remove docker docker-engine docker.io containerd runc

安装依赖包

apt-get install ca-certificates curl gnupg lsb-release

添加 Docker 的官方 GPG 密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

使用以下命令设置稳定存储库

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

安装 Docker和docker-compose

sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io  docker-compose
centos

删除旧版本的Docker(如果已安装):

sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine

添加Docker的yum仓库:

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

安装Docker引擎:

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

启动Docker服务并设置开机启动:

sudo systemctl start docker
sudo systemctl enable docker

确认Docker是否安装成功:

docker --version

安装Docker Compose:

sudo curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose

确认Docker Compose是否安装成功:

docker-compose --version

留言

您的电子邮箱地址不会被公开。 必填项已用 * 标注