这篇“CentOS7下如何安装配置Docker”文章的知识点大部分人都不太理解,所以小编给大家总结了以下内容,内容详细,步骤清晰,具有一定的借鉴价值,希望大家阅读完这篇文章能有所收获,下面我们一起来看看这篇“CentOS7下如何安装配置Docker”文章吧。

1 安装 Docker

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

[root@Docker]#yumremove-ydockerdocker-iodocker-selinuxpython-docer-py

安装 Docker-CE社区版本

[root@Docker]#yum-yinstalldocker-ce

启动 Docker

[root@Docker]#systemctlstartdocker[root@Docker]#systemctlenabledockerCreatedsymlinkfrom/etc/systemd/system/multi-user.target.wants/docker.serviceto/usr/lib/systemd/system/docker.service.[root@Docker]#systemctlstatusdocker●docker.service-DockerApplicationContainerEngineLoaded:loaded(/usr/lib/systemd/system/docker.service;enabled;vendorpreset:disabled)Active:active(running)sinceMon2020-03-3013:17:47EDT;16sagoDocs:https://docs.docker.comMainPID:12932(dockerd)CGroup:/system.slice/docker.service└─12932/usr/bin/dockerd-Hfd://--containerd=/run/contain...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockerdockerd[12932]:time="2020-0...Mar3013:17:47Dockersystemd[1]:StartedDockerA...Hint:Somelineswereellipsized,use-ltoshowinfull.[root@Docker]#dockerversionClient:DockerEngine-CommunityVersion:19.03.8APIversion:1.40Goversion:go1.12.17Gitcommit:afacb8bBuilt:WedMar1101:27:042020OS/Arch:linux/amd64Experimental:falseServer:DockerEngine-CommunityEngine:Version:19.03.8APIversion:1.40(minimumversion1.12)Goversion:go1.12.17Gitcommit:afacb8bBuilt:WedMar1101:25:422020OS/Arch:linux/amd64Experimental:falsecontainerd:Version:1.2.13GitCommit:7ad184331fa3e55e52b890ea95e65ba581ae3429runc:Version:1.0.0-rc10GitCommit:dc9208a3303feef5b3839f4323d9beb36df0a9dddocker-init:Version:0.18.0GitCommit:fec36832 指定docker 镜像加速器 (很重要,不然后期从国外下载docker镜像会直接报错,而且速度慢)

国内docker仓库加速站点

https://registry.docker-cn.comhttp://hub-mirror.c.163.comhttps://3laho3y3.mirror.aliyuncs.comhttp://f1361db2.m.daocloud.iohttps://mirror.ccs.tencentyun.comhttps://docker.mirrors.ustc.edu.cnhttp://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]#systemctldaemon-reload[root@Docker]#systemctlrestartdocker&&systemctlstatusdocker4 显示 Docker 系统信息

[root@Docker]#dockerinfoClient:DebugMode:falseServer:Containers:0Running:0Paused:0Stopped:0Images:0ServerVersion:19.03.8StorageDriver:overlay2BackingFilesystem:Supportsd_type:trueNativeOverlayDiff:trueLoggingDriver:json-fileCgroupDriver:cgroupfsPlugins:Volume:localNetwork:bridgehostipvlanmacvlannulloverlayLog:awslogsfluentdgcplogsgelfjournaldjson-filelocallogentriessplunksyslogSwarm:inactiveRuntimes:runcDefaultRuntime:runcInitBinary:docker-initcontainerdversion:7ad184331fa3e55e52b890ea95e65ba581ae3429runcversion:dc9208a3303feef5b3839f4323d9beb36df0a9ddinitversion:fec3683SecurityOptions:seccompProfile:defaultKernelVersion:3.10.0-957.el7.x86_64OperatingSystem:CentOSLinux7(Core)OSType:linuxArchitecture:x86_64CPUs:2TotalMemory:7.62GiBName:DockerID:SZWH:KWZM:GDQA:ZRHY:PU7A:JV23:7TX3:SYUM:J3UX:ZEOR:JG44:SDHLDockerRootDir:/var/lib/dockerDebugMode:falseRegistry:https://index.docker.io/v1/Labels:Experimental:falseInsecureRegistries:127.0.0.0/8RegistryMirrors:https://registry.docker-cn.comLiveRestoreEnabled:falseWARNING:IPv4forwardingisdisabledWARNING:bridge-nf-call-iptablesisdisabledWARNING:bridge-nf-call-ip6tablesisdisabled5 测试拉取 Docker 镜像

[root@Docker]#dockerimagepullcentos:latestlatest:Pullingfromlibrary/centos8a29a15cefae:PullcompleteDigest:sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700Status:Downloadednewerimageforcentos:latestdocker.io/library/centos:latest#拉取Docker镜像成功[root@Docker]#dockerimagesREPOSITORYTAGIMAGEIDCREATEDSIZEcentoslatest470671670cac2monthsago237MB

以上就是关于“CentOS7下如何安装配置Docker”这篇文章的内容,相信大家都有了一定的了解,希望小编分享的内容对大家有帮助,若想了解更多相关的知识内容,请关注亿速云行业资讯频道。