【边玩边学K8S】【002】安装Docker

编程入门 行业动态 更新时间:2024-10-25 20:22:07

【边玩<a href=https://www.elefans.com/category/jswz/34/1753935.html style=边学K8S】【002】安装Docker"/>

【边玩边学K8S】【002】安装Docker

安装Docker

安装

[root@host01 ~]# yum makecache
[root@host01 ~]# yum install docker
[root@host01 ~]# yum install golang

启动

[root@host01 ~]# systemctl enable docker
[root@host01 ~]# systemctl start docker
[root@host01 ~]# docker version
Client:Version:         1.13.1API version:     1.26Package version: docker-1.13.1-68.gitdded712.el7.centos.x86_64Go version:      go1.9.4Git commit:      dded712/1.13.1Built:           Tue Jul 17 18:34:48 2018OS/Arch:         linux/amd64Server:Version:         1.13.1API version:     1.26 (minimum version 1.12)Package version: docker-1.13.1-68.gitdded712.el7.centos.x86_64Go version:      go1.9.4Git commit:      dded712/1.13.1Built:           Tue Jul 17 18:34:48 2018OS/Arch:         linux/amd64Experimental:    false

配置Docker代理(有条件可选)

Environment="HTTP_PROXY=http://用户名:密码@代理IP:端口"
Environment="HTTPS_PROXY=http://用户名:密码@代理IP:端口"
Environment="NO_PROXY=localhost,127.0.0.1"

追加代理配置内容到/lib/systemd/system/docker.service中的Environment段的下面

重启

[root@host01 ~]# systemctl daemon-reload
[root@host01 ~]# systemctl restart docker

配置用户(有条件可选)

[root@host01 ~]# groupadd docker
[root@host01 ~]# usermod -aG docker $USER
非root用户执行时,需要创建docker用户组,将当前用户加入docker用户组

验证

[root@host01 ~]# docker run hello-worldHello from Docker!
This message shows that your installation appears to be working correctly.To generate 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 theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID: more examples and ideas, visit:/

在公司内部进行docker pull时,由于通常要经过代理,有可能会由于证书问题导致镜像无法pull下来,此时需要以下解决方案

  1. 获取公司代理的证书(以Chrome为例,打开一个可以打开的外网,打开地址栏的安全按钮,查看证书详细信息,复制证书,采用默认格式导出证书即可。)
  2. 将证书改名为cacert.pem
  3. 将cacert.pem放到CentOS的/etc/pki/ca-trust/source/anchors下
  4. 执行update-ca-trust命令使其生效

更多推荐

【边玩边学K8S】【002】安装Docker

本文发布于:2024-02-08 21:36:59,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1675321.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:边学   K8S   Docker

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!