docker安装

一,编辑网卡,使虚拟机能连接网络

[root@localhost ~]# vi /etc/sysconfig/network-scripts/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=39316931-1b5c-4378-87d3-c836be69a104
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.1.5
NETMASK=255.255.255.0
GATEWAY=192.168.1.2
DNS1=8.8.8.8
DNS2=8.8.4.4

ping百度测试

[root@localhost ~]# ping www.baidu.com
PING www.wshifen.com (103.235.46.39) 56(84) bytes of data.
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=5 ttl=128 time=334 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=8 ttl=128 time=335 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=9 ttl=128 time=334 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=11 ttl=128 time=334 ms
64 bytes from 103.235.46.39 (103.235.46.39): icmp_seq=12 ttl=128 time=334 ms
^C
--- www.wshifen.com ping statistics ---
13 packets transmitted, 6 received, 53% packet loss, time 12010ms
rtt min/avg/max/mdev = 334.114/334.543/335.057/0.455 ms

二,设置yum源
1.备份yum源

[root@localhost ~]# mkdir /opt/bak
[root@localhost ~]# mv /etc/yum.repos.d/* /opt/bak/

2.手动下载repo文件并上传到/etc/yum.repos.d/目录
link
3. 清除系统yum缓存并生成新的yum缓存
yum clean all # 清除系统所有的yum缓存
yum makecache # 生成yum缓存
4. 安装epel源
yum list | grep epel-release
yum install -y epel-release
5. 再次清除系统yum缓存,并重新生成新的yum缓存
yum clean all
yum makecache
6. 查看系统可用的yum源和所有的yum源
yum repolist enabled
yum repolist all
三,安装docker
1.查看内核版本

[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

2.更新yun包

[root@localhost ~]# yum update -y

3.安装需要的软件包

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

4.设置yum源

[root@localhost ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

5.安装docker
查看仓库中所有docker版本,并选择特定版本安装

[root@localhost ~]# yum list docker-ce --showduplicates | sort -r

安装docker

[root@localhost ~]# yum install docker-ce -y

6.启动docker

[root@localhost ~]# systemctl start docker

7.配置镜像加速

[root@localhost ~]# vi /etc/docker/daemon.json
{
  "registry-mirrors": ["https://br10hqrl.mirror.aliyuncs.com"]
}
[root@localhost ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker

8.测试

[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:8e3114318a995a1ee497790535e7b88365222a21771ae7e53687ad76563e8e76
Status: Downloaded newer image for hello-world:latest

Hello 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 the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

9.解决docker info 警告

[root@localhost ~]# vi /etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
[root@localhost ~]# sysctl -p
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值