在 centOS 上安装 docker
in Note with 0 comment
在 centOS 上安装 docker
in Note with 0 comment

安装docker

sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum-config-manager --disable docker-ce-edge
sudo yum makecache fast
sudo yum install -y docker-ce

配置阿里云代理

sudo cp -n /lib/systemd/system/docker.service /etc/systemd/system/docker.service
sudo mkdir -p /home/docker_lib
sudo sed -i "s|ExecStart=/usr/bin/dockerd|ExecStart=/usr/bin/dockerd -g /home/docker_lib --registry-mirror=https://ny0lp769.mirror.aliyuncs.com|g" /etc/systemd/system/docker.service
sudo sh -c "echo '{ \"storage-driver\": \"devicemapper\" }' > /etc/docker/daemon.json"
sudo systemctl daemon-reload
sudo service docker restart

// 拉一个 hello-world 的镜像测试
sudo docker run hello-world

不需要sudo运行docker

sudo groupadd docker
sudo usermod -aG docker $USER
Responses