文章

Docker安装

Docker安装

安装部署

rocky

人生苦短:如果出现安装失败可以尝试禁用ipv6

1
2
3
4
yum update -y && yum install yum-utils device-mapper-persistent-data lvm2 -y && \
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo && \
yum install docker-ce -y && \
systemctl start docker && systemctl enable docker

安装必要的依赖

1
yum update -y && yum install yum-utils device-mapper-persistent-data lvm2 -y

添加 docker-ce repo

1
wget -O /etc/yum.repos.d/docker-ce.repo https://download.docker.com/linux/centos/docker-ce.repo

安装 Docker

1
yum install docker-ce -y

启动 Docker 服务

1
systemctl start docker && systemctl enable docker

Ubuntu

安装必要的依赖
1
apt-get update && apt-get install apt-transport-https ca-certificates curl software-properties-common -y  
添加 Docker 的 GPG 密钥
1
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -  
添加 Docker stable 仓库
1
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"  
安装 Docker
1
apt-get update && apt-get install docker-ce -y  
启动 Docker 服务
1
systemctl start docker && systemctl enable docker  

docker-compose安装

1
wget https://github.com/docker/compose/releases/download/v2.30.1/docker-compose-linux-x86_64 -O /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose && docker-compose version

验收

image-20241106002145876

本文由作者按照 CC BY 4.0 进行授权