1.卸载旧版本

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

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker

2. 需要的安装包sudo yum install -y yum-utils

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_安装包_02

3. 设置镜像仓库,用阿里云的

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

更新yum软件包索引yum makecache fast

4. 安装docker docker-ce 社区 ee 企业版sudo yum install docker-ce docker-ce-cli containerd.io

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_03

5. 启动docker systemctl start docker

6. 测试docker是否安装成功,docker version

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_linux_04

7. 测试是否可以运行镜像sudo docker run hello-world

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_05

8. 配置阿里云镜像加速

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://mu8fm028.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

9. 设置docker开机自启sudo systemctl enable docker

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_06

10.设置docker立即启动以及开机启动

sudo systemctl enable docker --now

77、提交自己的镜像

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_07

centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_08

88、把当前提交的镜像传给其他人有两种方式

  • 压缩包发送过去
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_linux_09
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_linux_10
    在另一台机器加载镜像
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_安装包_11
  • 推送到docker hub
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_安装包_12
    可以先利用docker tag命令加上用户前缀(首先需要在docker hub注册账户)
    docker push的时候需要先登陆
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_linux_13
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_14
    在另一台机器就可以docker pull了
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_15
    可以启动了
    centos7安装docker(参考官网:https://docs.docker.com/engine/install/centos/)_docker_16