1-docker安装

一、设置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://自己的阿里云的数字.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.


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值