在centos7中安装docker的相关环境

环境简介
操作系统:CentOS是最小化安装
机器的ip:192.168.0.205

---------------开始安装------------------------------
修改机器名称
hostnamectl --static set-hostname node205

由于显示有乱码,在ssh客户端上临时设置显示字符级
export LANG=zh_CN.gbk

检查内网是否通,ping 204
[root@node205 ~]# ping 192.168.0.204
PING 192.168.0.204 (192.168.0.204) 56(84) bytes of data.
64 bytes from 192.168.0.204: icmp_seq=1 ttl=64 time=0.120 ms
64 bytes from 192.168.0.204: icmp_seq=2 ttl=64 time=0.116 ms
64 bytes from 192.168.0.204: icmp_seq=3 ttl=64 time=0.123 ms
^C
— 192.168.0.204 ping statistics —
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.116/0.119/0.123/0.012 ms

检查外网是否通
[root@node205 ~]# ping www.baidu.com
ping: www.baidu.com: 未知的名称或服务

以下需要解决连接外网

查看当前网卡信息
[root@node205 ~]# nmcli connection show
NAME UUID TYPE DEVICE
ens160 8b7efc2d-d2af-4fce-a41b-c8eaf0a237e5 ethernet ens160
证明外网通过ens160连接。

检查网卡的连接状态
nmcli connection show

修改ens160的连接配置文件
网卡的配置文件放在/etc/sysconfig/network-scripts目录中ifcfg-ens160
修改这个文件
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=8b7efc2d-d2af-4fce-a41b-c8eaf0a237e5
DEVICE=ens160
ONBOOT=yes
IPADDR0=192.168.0.205
PREFIXO0=24
GATEWAY0=192.168.0.1
DNS1=8.8.8.8
DNS2=8.8.4.4

ZONE=public

完成更新后重新启动
reboot

通过ssh终端连接到205服务器
检查外网是否畅通
[root@node205 ~]# ping www.baidu.com
PING www.baidu.com (14.215.177.38) 56(84) bytes of data.
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=1 ttl=54 time=19.2 ms
64 bytes from 14.215.177.38 (14.215.177.38): icmp_seq=2 ttl=54 time=19.0 ms

[root@node205 ~]# ifconfig
-bash: ifconfig: 未找到命令
[root@node205 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
证明没有安装ifconfig,需要连接安装

安装ifconfig
yum install net-tools.x86_64

安装完成后查看信息
[root@node205 ~]# ifconfig
ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.0.205 netmask 255.255.255.0 broadcast 192.168.0.255
inet6 fe80::d792:fa0f:7857:6cd7 prefixlen 64 scopeid 0x20
ether 00:50:56:ae:c3:af txqueuelen 1000 (Ethernet)
RX packets 10998 bytes 13884873 (13.2 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 9129 bytes 819355 (800.1 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
inet6 ::1 prefixlen 128 scopeid 0x10
loop txqueuelen 1000 (Local Loopback)
RX packets 32 bytes 2592 (2.5 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32 bytes 2592 (2.5 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

机器的网络相关配置完成,以下安装Docker相关
sudo yum remove docker docker-common docker-selinux docker-engine
删除旧版本
[root@node205 ~]# sudo yum remove docker docker-common docker-selinux docker-engine

安装需要的软件包yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2

设置yun源
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

建立元数据缓存
sudo yum makecache fast

安装docker latest版本
sudo yum -y install docker-ce

查看docker 相关信息
[root@node205 ~]# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:03 2018
OS/Arch: linux/amd64
Experimental: false

启动docker
systemctl restart docker

查看docker状态
[root@node205 ~]# docker version
Client:
Version: 18.06.1-ce
API version: 1.38
Go version: go1.10.3
Git commit: e68fc7a
Built: Tue Aug 21 17:23:03 2018
OS/Arch: linux/amd64
Experimental: false
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@node205 ~]# systemctl restart docker
[root@node205 ~]# ^C
[root@node205 ~]# docker info
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.06.1-ce
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.702GiB
Name: node205
ID: 3J2G:2EWC:XIV6:WZ75:QCUC:7G2E:WUKS:KQE6:EH6L:4PYA:PGND:URUB
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/

将docker服务设置成开机启动
[root@node205 ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

---------------docker安装完毕-------------------------

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值