docker 及docker-compose安装

2021 年 6 月 23 日 星期三
/
21

docker 及docker-compose安装

安装docker

curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

或者 ```bash

移除掉旧的版本

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

删除所有旧的数据

sudo rm -rf /var/lib/docker

安装依赖包

sudo yum install -y yum-utils \ device-mapper-persistent-data \ lvm2

添加源,使用了阿里云镜像

sudo yum-config-manager \ --add-repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

配置缓存

sudo yum makecache fast

安装最新稳定版本的docker

sudo yum install -y docker-ce

配置镜像加速器

sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["http://hub-mirror.c.163.com"] } EOF

启动docker引擎并设置开机启动

sudo systemctl start docker sudo systemctl enable docker

配置当前用户对docker的执行权限

sudo groupadd docker sudo gpasswd -a ${USER} docker sudo systemctl restart docker ```

docker-compose

curl -L "https://github.91chi.fun/https://github.com//docker/compose/releases/download/v2.5.1/docker-compose-linux-x86_64" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
  • Loading...
  • Loading...
  • Loading...
  • Loading...
  • Loading...