Blog.L

Blog.L

安装 docker、docker-compose

114
2023-09-10

安装 docker

1、查看Linux版本

cat /etc/os-release
版本显示(华为云)
NAME="Huawei Cloud EulerOS"

VERSION="2.0 (x86_64)"

ID="hce"

VERSION_ID="2.0"

PRETTY_NAME="Huawei Cloud EulerOS 2.0 (x86_64)"

ANSI_COLOR="0;31"

2、移除docker

sudo yum remove docker \

>                   docker-client \

>                   docker-client-latest \

>                   docker-common \

>                   docker-latest \

>                   docker-latest-logrotate \

>                   docker-logrotate \

>                   docker-engine \

>                   podman \

>                   runc

3、安装(华为云)

阿里云支持一次性安装 docker 和 docker compose

wget https://repo.huaweicloud.com/repository/conf/openeuler_x86_64.repo -O /etc/yum.repos.d/openEuler.repo
yum clean all
yum makecache
yum -y install docker

4、配置 Docker 镜像加速器

vi /etc/docker/daemon.json
添加下面阿里云
{"registry-mirrors":["https://uf69c6k9.mirror.aliyuncs.com"]}
让配置生效
systemctl daemon-reload
重启docker
systemctl restart docker

安装 docker-compose(本地上传安装)

1、查看官网版本

https://github.com/docker/compose/releases

curl -SL https://github.com/docker/compose/releases/download/v2.21.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

找到 docker-compose-linux-x86_64 并下载,然后上传到 /usr/local/bin 目录下

2、重命名

mv docker-compose-linux-x86_64 docker-compose

3、添加权限

sudo chmod +x /usr/local/bin/docker-compose

4、查看版本

docker-compose --version