一、设置IP和检查网络的连通性
1、设置IP
[root@localhost ~]# cd /etc/sysconfig/network-scripts/
l[root@localhost network-scripts]# ls
ifcfg-ens33 ifdown-ppp ifup-ib ifup-Team
[root@localhost network-scripts]# vi ifcfg-ens33
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=ens33
UUID=4112753a-3a96-4d89-847b-8095c7eadbe9
DEVICE=ens33
ONBOOT=yes
IPV6_PRIVACY=no
IPADDR=192.168.93.159
NETMASK=255.255.255.0
GATEWAY=192.168.93.2
DNS1=192.168.93.2
-----------------选项说明------------------------
BOOTPROTO=static 设置为固定IP
DEVICE=ens33 网卡名
ONBOOT=yes 启用
2、重启网络服务
[root@localhost network-scripts]# systemctl network restart
3、查看网络,必须像下面那样,如果只有第一条不可以PING baidu.com (39.156.69.79) 56(84) bytes of data.
[root@localhost ~]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=128 time=24.5 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=128 time=25.3 ms
二、安装docker
1、安装工具
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
2、[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
不成功多试几次,必须出现repo saved to /etc/yum.repos.d/docker-ce.repo
Loaded plugins: fastestmirror, langpacks
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
3、安docker
[root@localhost ~]# yum -y install docker-ce
4、启动
[root@localhost ~]# systemctl start docker
5、设置开机启动
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
6、设置镜像代理即改下载源要不然下载镜像的时候下载不下来,我用的是阿里云,用其它的也可以。
[root@localhost /]# cd /etc/docker
[root@localhost docker]# vi daemon.json
在里面输入自己的唯一值,登录上阿里云之后,搜索“容器镜像服务”之后点击开通就好。不用去设置别的,每个人生成都是唯一的值
[root@localhost /]# sudo mkdir -p /etc/docker
[root@localhost docker]# vi daemon.json
输入如下内容:
{
"registry-mirrors": ["https://换成自己申请的数字.mirror.aliyuncs.com"]
}
7、重载和重启
[root@localhost docker]# systemctl daemon-reload
[root@localhost docker]# systemctl restart docker
8、查看信息
[root@localhost docker]# docker info
Client:
Debug Mode: false
Server:
Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 19.03.8
Storage Driver: overlay2
backing Filesystem: <unkNown>
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
cpus: 1
Total Memory: 972.6MiB
Name: localhost.server1
ID: YNJF:2HH6:WPSH:Y2OS:OIWY:TR6N:OIIP:4A7B:SMLI:SPJR:AUTU:NTM7
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://8m6o6e30.mirror.aliyuncs.com/
Live Restore Enabled: false
9、pull镜像成功了
[root@localhost docker]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
10、查看
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest fce289e99eb9 14 months ago 1.84kB
11、运行
[root@localhost docker]# docker run hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。