您当前所在位置:首页安装教程01-docker系列-linux下的docker安装

01-docker系列-linux下的docker安装

更新:2023-08-11 13:02:51编辑:tooool归类:安装教程人气:85

新闻稿:责任编辑乃网络管理家创作者,转发请标明原文,更多文本请高度关注社会公众号网络管理家。

01-docker系列-linux下的docker安装

中心思想

从那时已经开始,将稳步三四个月,主要就预览docker有关文本,从进阶到上手采用。前面除了甚么想看的都能在前台回帖哦。快来高度关注我吧。

自然环境

linux伺服器,须要停用selinux和内网,过往该文有如是说具体内容形式
能上内网

检查和

[yunweijia@localhost ~]$ uname -r3.10.0-862.el7.x86_64
[yunweijia@localhost ~]$

大于3.10的就能加装docker。

移除旧版本

移除系统上的一些有关文本,不然加装起来容易遇到一些问题。

[yunweijia@localhost ~]$ sudo yum remove docker \>                   docker-client \>                   docker-client-latest \>                   docker-common \>                   docker-latest \>                   docker-latest-logrotate \>                   docker-logrotate \>                   docker-selinux \>                   docker-engine-selinux \>                   docker-engine[sudo] yunweijia 的密码:
已加载插件:fastestmirror, langpacks
参数 docker 没有匹配
参数 docker-client 没有匹配
参数 docker-client-latest 没有匹配
参数 docker-common 没有匹配
参数 docker-latest 没有匹配
参数 docker-latest-logrotate 没有匹配
参数 docker-logrotate 没有匹配
参数 docker-selinux 没有匹配
参数 docker-engine-selinux 没有匹配
参数 docker-engine 没有匹配
不删除任何软件包
[yunweijia@localhost ~]$

加装docker

加装必要的工具:

[yunweijia@localhost ~]$ sudo yum install -y yum-utils device-mapper-persistent-datalvm2

添加软件源信息:

[yunweijia@localhost ~]$ sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

预览软件源信息:

[yunweijia@localhost ~]$ yum clean all
[yunweijia@localhost ~]$ yum makecache fast

加装docker-ce(docker-ce版本是社区版本,免费,docker-ee是企业版本,收费):

[yunweijia@localhost ~]$ sudo yum -y install docker-ce

解决报错:

如果报错如下信息:
错误:软件包:containerd.io-1.4.12-3.1.el7.x86_64 (docker-ce-stable)
          须要:container-selinux >=2:2.74错误:软件包:docker-ce-rootless-extras-20.10.12-3.el7.x86_64 (docker-ce-stable)
          须要:slirp4netns >=0.4错误:软件包:docker-ce-rootless-extras-20.10.12-3.el7.x86_64 (docker-ce-stable)
          须要:fuse-overlayfs >=0.7错误:软件包:3:docker-ce-20.10.12-3.el7.x86_64 (docker-ce-stable)
          须要:container-selinux >=2:2.74解决:
我们须要升级一下有关软件,下载container-selinux;


[yunweijia@localhost ~]$ sudo wget -O/etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[yunweijia@localhost ~]$ yum clean all
[yunweijia@localhost ~]$ yum makecache fast
[yunweijia@localhost ~]$ sudo yum install epel-release -y
[yunweijia@localhost ~]$ sudo yum install container-selinux -

而后再次进行加装docker-ce:

[yunweijia@localhost ~]$ sudo yum -y install docker-ce

启动docker服务:

[yunweijia@localhost~]$sudosystemctlstartdocker[yunweijia@localhost~]$sudosystemctlstatusdockerdocker.service-DockerApplicationContainerEngineLoaded:loaded(/usr/lib/systemd/system/docker.service;disabled;vendor preset:disabled)Active:active(running)since2022-02-0815:37:14CST;7sagoDocs:https://docs.docker.comMain PID:5688(dockerd)Tasks:7Memory:30.0MCGroup:/system.slice/docker.service└─5688/usr/bin/dockerd-Hfd://--containerd=/run/containerd/containerd.sock20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.371959365+08:00"level=infomsg="scheme\"unix\"notregistered,fallbacktodef...dule=grpc20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.371974573+08:00"level=infomsg="ccResolverWrapper:sending update to cc:{[{uni...dule=grpc20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.371981256+08:00"level=infomsg="ClientConnswitchingbalancerto\"pick_first\"...dule=grpc20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.404169481+08:00"level=infomsg="Loadingcontainers:start."20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.496148517+08:00"level=infomsg="Defaultbridge(docker0)isassignedwithanIP...address"20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.545353512+08:00"level=infomsg="Loadingcontainers:done."20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.559734496+08:00"level=infomsg="Dockerdaemon"commit=459d0dfgraphdriver(s)=ov...=20.10.1220815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.560072640+08:00"level=infomsg="Daemonhascompletedinitialization"20815:37:14localhost.localdomainsystemd[1]:StartedDockerApplicationContainerEngine.20815:37:14localhost.localdomaindockerd[5688]:time="2022-02-08T15:37:14.588758976+08:00"level=infomsg="APIlistenon/var/run/docker.sock"Hint:Somelineswereellipsized,use-ltoshowinfull.[yunweijia@localhost~]$

测试运行hello-word:

[yunweijia@localhost~]$ sudo docker run hello-worldUnableto find image hello-world:latest locallylatest:Pulling from library/hello-world2db29710123e:Pull completeDigest:sha256:507ecde44b8eb741278274653120c2bf793b174c06ff4eaa672b713b3263477bStatus:Downloaded newer image for hello-world:latestHellofrom Docker!Thismessage shows that your installation appears to be working correctly.Togenerate this message, Docker took the following steps:1.The Docker client contacted the Docker daemon.2.The Docker daemon pulled the "hello-world" image from the Docker Hub.(amd64)3.The Docker daemon created a new container from that image which runs theexecutablethat produces the output you are currently reading.4.The Docker daemon streamed that output to the Docker client, which sent ittoyour terminal.Totry something more ambitious, you can run an Ubuntu container with:$docker run -it ubuntu bashShareimages, automate workflows, and more with a free Docker ID:https://hub.docker.com/Formore examples and ideas, visit:https://docs.docker.com/get-started/[yunweijia@localhost~]$

至此,linux中搭建docker完毕。

下一章:镜像分类以及操作(导入、导出、删除)

我告诉你msdn版权声明:以上内容作者已申请原创保护,未经允许不得转载,侵权必究!授权事宜、对本内容有异议或投诉,敬请联系网站管理员,我们将尽快回复您,谢谢合作!

win10系统设置默认程序失败如何解决 怎么正确的安装并使用云效Git控制系统

游客 回复需填写必要信息