centos7 docker安装

    技术2026-04-12  5

    centos7 docker安装

    linux环境设置国内镜像源开始安装

    linux环境

    centos7 4核 8G

    设置国内镜像源

    在 /etc/docker/daemon.json 文件中假如如下内容: {"registry-mirrors":["https://reg-mirror.qiniu.com/"]} 如果没有这个文件就创建一个。重新启动服务$ systemctl daemon-reload $ systemctl restart docker

    开始安装

    如果有旧版本需要先卸载

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

    设置docker仓库

    $ yum install -y yum-utils device-mapper-persistent-data lvm2

    使用阿里云镜像安装

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

    安装 Docker Engine-Community

    $ yum install docker-ce docker-ce-cli containerd.io

    运行docker

    $ systemctl start docker

    运行hello-world验证安装是否成功

    $ docker run hello-world
    Processed: 0.013, SQL: 12