CentOS7 安装 Docker具体步骤

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化,下面为大家分享一下CentOS7 安装 Docker具体步骤。

img

  • 1 安装 Docker

    如果有的话,卸载旧的Docker,否则可能会不兼容

    [root@Docker ]# yum remove -y docker docker-io docker-selinux python-docer-py

    安装 Docker-CE社区版本

    [root@Docker ]# yum -y install docker-ce

    启动 Docker

    [root@Docker  ]# systemctl start docker
    [root@Docker  ]# systemctl enable docker
    Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
    [root@Docker  ]# systemctl status docker
    ● docker.service - Docker Application Container Engine
      Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
      Active: active (running) since Mon 2020-03-30 13:17:47 EDT; 16s ago
        Docs: https://docs.docker.com
    Main PID: 12932 (dockerd)
      CGroup: /system.slice/docker.service
              └─12932 /usr/bin/dockerd -H fd:// --containerd=/run/contain...
    
    Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0... Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0...
    Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0... Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0...
    Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0... Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0...
    Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0... Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0...
    Mar 30 13:17:47 Docker dockerd[12932 ]: time="2020-0... Mar 30 13:17:47 Docker systemd[1 ]: Started Docker A... Hint: Some lines were ellipsized, use -l to show in full. [root@Docker  ]# docker version Client: Docker Engine - Community Version:           19.03.8 API version:       1.40 Go version:        go1.12.17 Git commit:        afacb8b Built:             Wed Mar 11 01:27:04 2020 OS/Arch:           linux/amd64 Experimental:      false Server: Docker Engine - Community Engine:  Version:          19.03.8  API version:      1.40 (minimum version 1.12)  Go version:       go1.12.17  Git commit:       afacb8b  Built:            Wed Mar 11 01:25:42 2020  OS/Arch:          linux/amd64  Experimental:     false containerd:  Version:          1.2.13  GitCommit:        7ad184331fa3e55e52b890ea95e65ba581ae3429 runc:  Version:          1.0.0-rc10  GitCommit:        dc9208a3303feef5b3839f4323d9beb36df0a9dd docker-init:  Version:          0.18.0  GitCommit:        fec3683 

    2 指定docker 镜像加速器 (很重要,不然后期从国外下载docker镜像会直接报错,而且速度慢)

    国内docker仓库加速站点

    https://registry.docker-cn.com
    http://hub-mirror.c.163.com
    https://3laho3y3.mirror.aliyuncs.com
    http://f1361db2.m.daocloud.io
    https://mirror.ccs.tencentyun.com
    https://docker.mirrors.ustc.edu.cn  
    http://dockerhub.azk8s.cn/
    

    配置加速节点

    [root@Docker ]# vim /etc/docker/daemon.json
    {
     "registry-mirrors": ["https://registry.docker-cn.com" ]  
    }
    

    注意不可见字符! 注:如果需要使用自己的本地私有仓库,写成如下:

    {
     "registry-mirrors": ["https://e9yneuymirror.aliyuncs.com" ]  
     "insecure-registries": ["192.168.10.7:4000" ]
    }
    

    另外的参考配置:

    {
     "insecure-registries": ["0.0.0.0/0" ],
     "log-opts": {
       "max-size""20m",
       "max-file""5"
     }
    }
    

    3 重启相关服务

    [root@Docker ]# systemctl daemon-reload
    [root@Docker ]# systemctl restart docker && systemctl status docker

    4 显示 Docker 系统信息

    [root@Docker ]# docker info
    Client:
     Debug Mode: false
    
    Server:
     Containers: 0
      Running: 0
      Paused: 0
      Stopped: 0
     Images: 0
     Server Version: 19.03.8
     Storage Driver: overlay2
      Backing Filesystem: 
      Supports d_type: true
      Native Overlay Diff: true
     Logging Driver: json-file
     Cgroup Driver: cgroupfs
     Plugins:
      Volume: local
      Network: bridge host ipvlan macvlan null overlay
      Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
     Swarm: inactive
     Runtimes: runc
     Default Runtime: runc
     Init Binary: docker-init
     containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
     runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
     init version: fec3683
     Security Options:
      seccomp
       Profile: default
     Kernel Version: 3.10.0-957.el7.x86_64
     Operating System: CentOS Linux 7 (Core)
     OSType: linux
     Architecture: x86_64
     CPUs: 2
     Total Memory: 7.62GiB
     Name: Docker
     ID: SZWH:KWZM:GDQA:ZRHY:PU7A:JV23:7TX3:SYUM:J3UX:ZEOR:JG44:SDHL
     Docker Root Dir: /var/lib/docker
     Debug Mode: false
     Registry: https://index.docker.io/v1/
     Labels:
     Experimental: false
     Insecure Registries:
      127.0.0.0/8
     Registry Mirrors:
      https://registry.docker-cn.com
     Live Restore Enabled: false
    
    WARNING: IPv4 forwarding is disabled
    WARNING: bridge-nf-call-iptables is disabled
    WARNING: bridge-nf-call-ip6tables is disabled
    

    5 测试拉取 Docker 镜像

    [root@Docker ]# docker image pull centos:latest
    latest: Pulling from library/centos
    8a29a15cefae: Pull complete 
    Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700
    Status: Downloaded newer image for centos:latest
    docker.io/library/centos:latest
    #拉取 Docker 镜像成功
    [root@Docker ]# docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    centos              latest              470671670cac        2 months ago        237MB
    

文章来源网络,作者:运维,如若转载,请注明出处:https://shuyeidc.com/wp/210879.html<

(0)
运维的头像运维
上一篇2025-04-10 03:28
下一篇 2025-04-10 03:30

相关推荐

  • hypervmart美国是什么?hypervmart美国官网入口

    2026 年 Hypervmart 美国站已全面接入 AI 智能选品与跨境物流自动化系统,成为中小卖家切入北美市场的首选低成本独立站解决方案,其核心优势在于“零库存 + 高转化”的闭环模式,随着 2026 年全球跨境电商进入“精细化运营”深水区,Hypervmart 美国站凭借其对北美消费者行为的深度洞察,在独……

    2026-05-02
    0
  • hypervmart是什么,hypervmart官网入口

    hypervmart 在 2026 年是否值得投资?核心结论:是,但需精准匹配供应链场景hypervmart 作为 2026 年跨境零售与 B2B 融合的新兴平台,其核心价值在于利用 AI 驱动的供应链优化技术,为中小卖家提供低于行业平均 15% 的履约成本,但成功与否高度依赖卖家对“跨境物流时效”与“海外仓选……

    2026-05-02
    0
  • RAKsmart独立服务器2026年测评,CN2 GIA实测数据与性能表现,CN2 GIA服务器到底怎么样,CN2 GIA独立服务器推荐

    RAKsmart 独立服务器在 2026 年已确立为连接中国内地与全球的高性能网络枢纽,其 CN2 GIA 线路实测延迟稳定在 35ms 以内,吞吐量突破 900Mbps,是跨境业务场景下兼顾稳定性与性价比的优选方案,核心网络性能深度解析2026 年 CN2 GIA 线路实测数据在 2026 年的网络架构中,R……

    2026-05-02
    0
  • hosteonsVPS测评,实测体验,hosteonsVPS怎么样?

    Hosteons VPS 在 2026 年的实测表现显示,其依托全球 BGP 线路优化与 NVMe 全闪存架构,在亚洲至北美跨洋延迟控制上表现优异,是追求高性价比与稳定性的中小型企业首选,但需注意其部分机房在晚高峰期的波动风险,核心性能与网络架构深度解析在 2026 年云计算基础设施全面向 AI 算力与边缘计算……

    2026-05-02
    0
  • BaCloud独立服务器测评不限流量实测表现,BaCloud独立服务器不限流量怎么样

    2026 年实测结论:BaCloud 独立服务器在不限流量场景下表现优异,特别适合高并发视频流媒体与大数据传输业务,其性价比与稳定性在同类竞品中处于第一梯队,但需关注其节点覆盖密度,在 2026 年云计算市场进入存量博弈与精细化运营并存的阶段,企业用户对于“不限流量”的诉求已从单纯的带宽大小转向实际吞吐能力与计……

    2026-05-02
    0

发表回复

您的邮箱地址不会被公开。必填项已用 * 标注