企业运维----Docker-简介、部署、镜像


简介

1.什么是Docker

Docker 是一个开源的应用容器引擎,基于 Go 语言并遵从 Apache2.0 协议开源;
Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级、可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化;
容器是完全使用沙箱机制,相互之间不会有任何接口,更重要的是容器性能开销极低;
Docker 从 17.03 版本之后分为 CE(Community Edition-社区版)和 EE(Enterprise Edition-企业版)。

2.Docker的应用场景

Web应用的自动化打包和发布,自动化测试和持续集成、发布;
在服务型环境中部署和调整数据库或其他的后台应用;
从头编译或者扩展现有的 OpenShift 或 Cloud Foundry 平台来搭建自己的 PaaS 环境。

部署

1.yum源的环境
[root@foundation12 Desktop]# cd /var/www/html/
[root@foundation12 html]# 
[root@foundation12 html]# ls
3000  4.0  apache-tomcat-7.0.90.tar.gz  docker-ce  nginx-1.20.1.tar.gz  rhel7.6
[root@foundation12 html]# cd docker-ce/
[root@foundation12 docker-ce]# ls
containerd.io-1.2.10-3.2.el7.x86_64.rpm
containerd.io-1.2.13-3.1.el7.x86_64.rpm
containerd.io-1.2.13-3.2.el7.x86_64.rpm
containerd.io-1.3.7-3.1.el7.x86_64.rpm
containerd.io-1.4.4-3.1.el7.x86_64.rpm
container-selinux-2.77-1.el7.noarch.rpm
docker-ce-18.09.9-3.el7.x86_64.rpm
docker-ce-19.03.11-3.el7.x86_64.rpm
docker-ce-19.03.12-3.el7.x86_64.rpm
docker-ce-19.03.13-3.el7.x86_64.rpm
docker-ce-19.03.15-3.el7.x86_64.rpm
docker-ce-19.03.5-3.el7.x86_64.rpm
docker-ce-19.03.8-3.el7.x86_64.rpm
docker-ce-cli-18.09.9-3.el7.x86_64.rpm
docker-ce-cli-19.03.11-3.el7.x86_64.rpm
docker-ce-cli-19.03.12-3.el7.x86_64.rpm
docker-ce-cli-19.03.13-3.el7.x86_64.rpm
docker-ce-cli-19.03.15-3.el7.x86_64.rpm
docker-ce-cli-19.03.5-3.el7.x86_64.rpm
docker-ce-cli-19.03.8-3.el7.x86_64.rpm
repodata
[root@foundation12 docker-ce]# 

[root@server1 ~]# cd /etc/yum.repos.d/
[root@server1 yum.repos.d]# ls
dvd.repo  redhat.repo  salt.repo  zabbix.repo
[root@server1 yum.repos.d]# vim docker.repo
[root@server1 yum.repos.d]# cat docker.repo 
[docker]
name=docker-ce
baseurl=http://172.25.12.250/docker-ce
gpgcheck=0
[root@server1 yum.repos.d]# yum repolist 
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
docker                                                   | 3.0 kB     00:00     
docker/primary_db                                          |  14 kB   00:00     
repo id                             repo name                             status
docker                              docker-ce                                20
dvd                                 dvd                                   5,152
salt                                salt 3000                                18
zabbix                              zabbix                                   22
repolist: 5,212
2.安装启动docker-ce

[root@server1 yum.repos.d]# yum install -y docker-ce

Installed:
  docker-ce.x86_64 3:19.03.15-3.el7                                             

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.4-4.el7                                        
  checkpolicy.x86_64 0:2.5-8.el7                                                
  container-selinux.noarch 2:2.77-1.el7                                         
  containerd.io.x86_64 0:1.4.4-3.1.el7                                          
  docker-ce-cli.x86_64 1:19.03.15-3.el7                                         
  libcgroup.x86_64 0:0.41-20.el7                                                
  libsemanage-python.x86_64 0:2.5-14.el7                                        
  policycoreutils-python.x86_64 0:2.5-29.el7                                    
  python-IPy.noarch 0:0.75-6.el7                                                
  setools-libs.x86_64 0:3.3.8-4.el7                                             

Complete!

[root@server1 yum.repos.d]# systemctl enable --now docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

3.检测 Docker 系统信息
[root@server1 yum.repos.d]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 0
  Running: 0
  Paused: 0
  Stopped: 0
 Images: 0
 Server Version: 19.03.15
 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 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: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: Red Hat Enterprise Linux Server 7.6 (Maipo)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 991.1MiB
 Name: server1
 ID: HZG3:IPNH:OYZE:PHOA:S4FE:2APD:UPD5:NTON:7JLI:EGXT:WL6S:GDUJ
 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
 Live Restore Enabled: false

WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled

发现两条warning

[root@server1 ~]# sysctl -a | grep bridge-nf-call-iptables
net.bridge.bridge-nf-call-iptables = 0
sysctl: reading key "net.ipv6.conf.all.stable_secret"
sysctl: reading key "net.ipv6.conf.default.stable_secret"
sysctl: reading key "net.ipv6.conf.docker0.stable_secret"
sysctl: reading key "net.ipv6.conf.eth0.stable_secret"
sysctl: reading key "net.ipv6.conf.lo.stable_secret"
sysctl: reading key "net.ipv6.conf.veth614c0e8.stable_secret"
[root@server1 yum.repos.d]# cd /etc/sysctl.d/
[root@server1 sysctl.d]# ls
99-sysctl.conf
[root@server1 sysctl.d]# vim docker.conf
[root@server1 sysctl.d]# cat docker.conf 
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1

刷新内核文件

[root@server1 ~]# sysctl --system

[root@server1 ~]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 2
  Running: 1
  Paused: 0
  Stopped: 1
 Images: 21
 Server Version: 19.03.15
 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 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: 05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc version: 12644e614e25b05da6fd08a38ffa0cfe1903fdec
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: Red Hat Enterprise Linux Server 7.6 (Maipo)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 991.1MiB
 Name: server1
 ID: HZG3:IPNH:OYZE:PHOA:S4FE:2APD:UPD5:NTON:7JLI:EGXT:WL6S:GDUJ
 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
 Live Restore Enabled: false

[root@server1 sysctl.d]# ip addr

3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:d1:d9:d2:03 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

</

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值