docker环境部署


[root@localhost ~]# nmcli connection 
NAME UUID TYPE DEVICE 
virbr0 6f94f0d9-33fd-47c3-ae62-d36656c75bd5 bridge virbr0 
ens33 d08ff5fd-80ff-4644-a922-c34887ec1b5c ethernet -- 
有线连接 1 46f7ea84-35c8-35f5-bac7-24fee69b8f96 ethernet -- 
[shuai@localhost ~]# nmcli connection delete ens33
成功删除连接 'ens33'(a977c9d0-a7ea-4aaa-a5da-0e946d2ed292)。
[root@localhost ~]# nmcli connection add type ethernet con-name ens33 ifname ens33 
Warning: There is another connection with the name 'ens33'. Reference the connection by its uuid 'fa5406c4-98aa-48fb-ab64-f051ff9f4ba1'
连接“ens33”(fa5406c4-98aa-48fb-ab64-f051ff9f4ba1) 已成功添加。
[root@localhost ~]# nmcli connection modify ens33 ipv4.addresses 192.168.1.11/24
[root@localhost ~]# nmcli connection modify ens33 ipv4.method manual 
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33

[root@localhost ~]# vim /etc/resolv.conf     //添加路由地址

更改:虚拟网络编辑器

再点击NAT设置

然后把这里改成VMnet8(NET模式)

然后别忘了重启一下网卡服务

[root@localhost ~]# systemctl restart network

最后来测试一下能否ping通

先来ping一下网关
[root@localhost ~]# ping 192.168.1.2
PING 192.168.1.2 (192.168.1.2) 56(84) bytes of data.
64 bytes from 192.168.1.2: icmp_seq=1 ttl=128 time=0.261 ms
64 bytes from 192.168.1.2: icmp_seq=2 ttl=128 time=0.196 ms
再来ping一下公网ip
[root@localhost ~]# ping 114.114.114.114
PING 114.114.114.114 (114.114.114.114) 56(84) bytes of data.
64 bytes from 114.114.114.114: icmp_seq=1 ttl=128 time=13.0 ms
64 bytes from 114.114.114.114: icmp_seq=2 ttl=128 time=14.2 ms
最后再来ping一下本站的域名
[root@localhost ~]# ping www.shuaiguoer.com
PING www.shuaiguoer.com (39.107.94.239) 56(84) bytes of data.
64 bytes from 39.107.94.239 (39.107.94.239): icmp_seq=1 ttl=128 time=8.79 ms
64 bytes from 39.107.94.239 (39.107.94.239): icmp_seq=2 ttl=128 time=7.57 ms

最后确定能全部ping通

配置yum源

[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vim docker.repo
[docker]
name=docker-ce
baseurl=https://download.docker.com/linux/centos/7/x86_64/stable/
enabled=1
gpgcheck=0

如果出现下面这种报错
删除/var/run/yum.pid就好了

[root@localhost yum.repos.d]# rm -rf /var/run/yum.pid

安装docker

[root@localhost yum.repos.d]# yum -y install docker-ce

加速器

curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s <a href="http://f1361db2.m.daocloud.io">http://f1361db2.m.daocloud.io</a>

完成后会提示让我们 重启docker

重启docker并加入开机自启

[root@localhost yum.repos.d]# systemctl restart docker
[root@localhost yum.repos.d]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

最后测试成功拉取docker镜像

[root@localhost yum.repos.d]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
473ede7ed136: Pull complete 
c46b5fa4d940: Pull complete 
93ae3df89c92: Pull complete 
6b1eed27cade: Pull complete 
Digest: sha256:c5aaecd59b35e20f12265fba73ee1db4ff5888b7a4495c0596f0464aa77a4117
Status: Downloaded newer image for ubuntu:latest
Last modification:July 24th, 2020 at 12:07 am
如果觉得我的文章对你有用,请随意赞赏