配置yum源
> cd /etc/yum.repos.d/
> mkdir repo_bak
> mv *.repo repo_bak/
> wget http://mirrors.aliyun.com/repo/Centos-7.repo
> wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
> yum clean all
> yum makecache
卸载旧版本docker
sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
使用存储库安装docker
安装所需的包
sudo yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
使用以下命令设置稳定存储库。
sudo yum-config-manager \
--add-repo \
https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sudo yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
安装DOCKER CE
安装最新docker
sudo yum install docker-ce docker-ce-cli containerd.io
或者yum列出docker再进行安装
yum list docker-ce --showduplicates | sort -r
sudo yum install docker-ce- docker-ce-cli- containerd.io
例如,docker-ce-18.09.1
建立 加入docker 用户组
sudo groupadd docker
sudo usermod -aG docker $USER
启动Docker
sudo systemctl start docker
sudo systemctl enable docker
List Docker CLI commands
docker
docker container --help
查看版本
docker --version
查看有关Docker安装的更多详细信息
docker --version
docker version
docker info
测试hello-world
docker run hello-world
List Docker images
docker image ls
List Docker containers (running, all, all in quiet mode)
docker container ls
docker container ls --all
docker container ls -aq
卸载Docker CE
sudo yum remove docker-ce
sudo rm -rf /var/lib/docker
国内加速
vim /etc/docker/daemon.json
加入:
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
]
}
重启:
$ sudo systemctl daemon-reload
$ sudo systemctl restart docker
参考:
https://docs.docker.com/install/linux/docker-ce/centos/