赞
踩
- sudo yum remove docker \
- docker-client \
- docker-client-latest \
- docker-common \
- docker-latest \
- docker-latest-logrotate \
- docker-logrotate \
- docker-engine
安装所需的软件包。yum-utils 提供了 yum-config-manager ,并且 device mapper 存储驱动程序需要 device-mapper-persistent-data 和 lvm2。
- 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 install docker-ce docker-ce-cli containerd.io
- systemctl start docker
-
-
-
- # 重启 Docker
- systemctl restart docker
- # 停止 Docker
- systemctl stop docker
docker version
出现如下图所示结果表示安装成功
Docker 需要用户具有 sudo 权限,为了避免每次命令都输入sudo,可以把用户加入 Docker 用户组。
sudo usermod -aG docker $USER
systemctl enable docker
- sudo mkdir -p /etc/docker
-
- sudo tee /etc/docker/daemon.json <<-'EOF'
- {
- "registry-mirrors": ["https://3n4m4jry.mirror.aliyuncs.com"]
- }
- EOF
-
- sudo systemctl daemon-reload
-
- sudo systemctl restart docker
卸载docker
- sudo yum remove docker-ce docker-ce-cli containerd.io
-
- sudo rm -rf /var/lib/docker
- sudo apt update
-
- sudo apt-get install ca-certificates curl gnupg lsb-release
-
- curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
-
- sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
-
- sudo apt-get install docker-ce docker-ce-cli containerd.io
-
- # docker命令免sudo
- sudo gpasswd -a [用户名] docker
- newgrp docker
-
- # 开机自启
- systemctl enable docker
-
- # 阿里云镜像加速
- sudo mkdir -p /etc/docker
- sudo tee /etc/docker/daemon.json <<-'EOF'
- {
- "registry-mirrors": ["https://3n4m4jry.mirror.aliyuncs.com"]
- }
- EOF
-
- sudo systemctl daemon-reload
-
- sudo systemctl restart docker
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。