Centos7
# 卸载旧docker
sudo yum -y remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
# 安装docker依赖组件
sudo yum -y install yum-utils \
device-mapper-persistent-data \
lvm2
# 启用docker稳定库、使用阿里docker库yum源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# 安装docker
sudo yum -y install docker-ce docker-ce-cli containerd.io
# 开机启动与启动服务
sudo systemctl enable docker
sudo systemctl start docker
# 自动补齐功能 centos7安装自动补全软件包,这样docker就可以自动补全,重新登陆shell才能生效
yum -y install bash-completion
Debian
# 添加软件源的 GPG 密钥
curl -fsSL https://mirrors.aliyun.com/docker-ce/linux/debian/gpg | sudo apt-key add -
# 添加 Docker CE 软件源,add-apt-repository命令由apt-file包提供。
apt-get install apt-file
add-apt-repository "deb [arch=amd64] https://mirrors.aliyun.com/docker-ce/linux/debian $(lsb_release -cs) stable"
# 安装docker-ce
apt-get update
apt-get install docker-ce
apt-file update
Docker 使用国内源
编辑docker配置文件
sudo cat > /etc/docker/daemon.json <<EOF
{
"registry-mirrors": [
"https://kfwkfulq.mirror.aliyuncs.com",
"https://2lqq34jg.mirror.aliyuncs.com",
"https://pee6w651.mirror.aliyuncs.com",
"https://registry.docker-cn.com",
"http://hub-mirror.c.163.com"
],
"dns": ["8.8.8.8","8.8.4.4"]
}
EOF
重启服务
重启服务国内源才能生效
systemctl daemon-reload
systemctl restart docker
验证是否生效
验证是否生效,有输出https地址表示已生效
root@localhost# docker info | grep -A 6 "Registry Mirrors"
Registry Mirrors:
https://kfwkfulq.mirror.aliyuncs.com/
https://2lqq34jg.mirror.aliyuncs.com/
https://pee6w651.mirror.aliyuncs.com/
https://registry.docker-cn.com/
http://hub-mirror.c.163.com/
https://dockerhub.azk8s.cn/
安装docker-compose
docker-compose是容器编排工具
yum -y install epel-release
yum -y install docker-compose
安装docker可视化
群辉的docker可视化还是挺不错的,这个portainer还是有点欠缺~~~
docker run -d -p 9000:9000 \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
--name prtainer-test \
portainer/portainer