快速安装docker环境(照做就能装上)

Docker是一个容器技术。具有很强的可移植性。从本质上来说,他是一个虚拟机。以镜像为基础单位,可以将单个项目分批的做好打成包。然后具有很强的可移植性。彼此之间不影响。下次要是谁需要,就可以直接拿出来用了。
下面我们来介绍一下,基于Centos 7 系统环境下,如何快速安装docker环境!
[root@localhost ~]# ifconfig //查看服务器的ip地址,ens33是我的本地网卡
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.4 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::617f:ef93:80d4:e14e prefixlen 64 scopeid 0x20
inet6 240e:3a2:745:8d30:ea90:dfb7:2133:6e48 prefixlen 64 scopeid 0x0
ether 00:0c:29:87:af:a6 txqueuelen 1000 (Ethernet)
RX packets 352908 bytes 167723050 (159.9 MiB)
RX errors 0 dropped 235 overruns 0 frame 0
TX packets 108366 bytes 9290223 (8.8 MiB)
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 1828 bytes 160628 (156.8 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1828 bytes 160628 (156.8 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8e:d3:64 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

测试一下服务器是否可以上网
[root@localhost ~]# ping www.baidu.com //ping 公网域名 。可以看见icmp数据包时就可以了。
PING www.a.shifen.com (180.101.49.11) 56(84) bytes of data.
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=1 ttl=54 time=5.57 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=2 ttl=54 time=5.94 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=3 ttl=54 time=4.62 ms
64 bytes from 180.101.49.11 (180.101.49.11): icmp_seq=4 ttl=54 time=5.90 ms
^C

[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2 //这是为了确保docker顺利安装好所必需的依赖包
如果在这一步报错。就添加一下源。
[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost ~]# yum install epel-release

[root@localhost ~]# yum install container-selinux //照做就行

安装docker-ce
[root@localhost ~]# yum clean all //清理软件源
已加载插件:fastestmirror, langpacks
正在清理软件源: base epel extras updates zabbix zabbix-non-supported
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors

[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo //照着敲就行

[root@localhost ~]# yum makecache fast //生成元数据缓存

[root@localhost ~]# yum -y install docker-ce //安装docker-ce (社区版)

[root@localhost ~]# systemctl start docker.service //启动docker

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

[root@localhost ~]# ifconfig //这个时候注意看,多了一个docker0,代表docker安装成功
docker0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 172.17.0.1 netmask 255.255.0.0 broadcast 172.17.255.255
ether 02:42:86:be:21:47 txqueuelen 0 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.1.4 netmask 255.255.255.0 broadcast 192.168.1.255
inet6 fe80::617f:ef93:80d4:e14e prefixlen 64 scopeid 0x20
inet6 240e:3a2:745:8d30:ea90:dfb7:2133:6e48 prefixlen 64 scopeid 0x0
ether 00:0c:29:87:af:a6 txqueuelen 1000 (Ethernet)
RX packets 456859 bytes 309622054 (295.2 MiB)
RX errors 0 dropped 235 overruns 0 frame 0
TX packets 146203 bytes 12224280 (11.6 MiB)
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 1867 bytes 164060 (160.2 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 1867 bytes 164060 (160.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
inet 192.168.122.1 netmask 255.255.255.0 broadcast 192.168.122.255
ether 52:54:00:8e:d3:64 txqueuelen 1000 (Ethernet)
RX packets 0 bytes 0 (0.0 B)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 0 bytes 0 (0.0 B)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

[root@localhost ~]# docker version //查看docker的版本号,也可以证实docker已经成功安装
Client: Docker Engine - Community
Version: 20.10.10
API version: 1.41
Go version: go1.16.9
Git commit: b485636
Built: Mon Oct 25 07:44:50 2021
OS/Arch: linux/amd64
Context: default
Experimental: true

Server: Docker Engine - Community
Engine:
Version: 20.10.10
API version: 1.41 (minimum version 1.12)
Go version: go1.16.9
Git commit: e2f740d
Built: Mon Oct 25 07:43:13 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.11
GitCommit: 5b46e404f6b9f661a205e28d59c982d3634148f8
runc:
Version: 1.0.2
GitCommit: v1.0.2-0-g52b36a2
docker-init:
Version: 0.19.0
GitCommit: de40ad0

注意事项:1.一条一条按照我上面写的命令来敲,就可以完成docker的安装。
2. docker在安装的过程当中,我们要让服务器本身能够上网。
3. Darker在使用的过程当中,这些本身也要能够上网。因为docker服务大多数都是基于镜像而做出的操作。因此,Docker镜像的拉血,用需要访问公网。对我们的服务器必须能够上网。
4. 系统环境:centos 7.5

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

思诚代码块

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值