docker理解与基本操作

在理解docker之前,先了解一下传统云计算服务:iaas(Infeastructure as a service 基础设施即服务)、paas(platform as a service 平台即服务)、saas(software as a service 软件即服务)

三者的区别在于云服务提供的资源不同,saas>paas>iaas。
详见 http://www.ruanyifeng.com/blog/2017/07/iaas-paas-saas.html

容器云以容器为资源分割和调度的基本单位,封装整个软件运行时环境,提供用于构建、发布、和运行分布式应用的平台。docker就是一种容器云。
可以将docker理解为github,能够将镜像push到镜像仓库中,也可以将很多镜像资源pull到自己的docker主机,便于开发。

Docker环境信息*

$ docker info
Containers: 7 //容器
 Running: 6
 Paused: 0
 Stopped: 1
Images: 3 //镜像
Server Version: 18.06.1-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-693.el7.x86_64
Operating System: CentOS Linux 7 (Core) //操作系统
OSType: linux //操作系统类型
Architecture: x86_64
CPUs: 1
Total Memory: 1.796GiB
Name: VM_0_3_centos
ID: PLGB:VBRZ:XVRX:WZDB:MIE4:6PGM:S3EE:4V5H:PGRW:3C4K:GWO3:QRCE
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: cindy1997
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

默认配置下,centOS使用docker会有如下警告

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

此时需要在配置文件中配置内核参数

$ vim etc/sysctl.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
$ sysctl -p

启用相应功能,再次使用info命令查看docker环境信息,WARNING消除。

以搭建docker应用栈的形式理解docker命令

$ docker pull haproxy

docker pull : 主要用于从docker registry中拉取镜像或者仓库。
$ docker images
可查看当前主机上的镜像,默认显示最顶层的镜像,使用-a可查看所有镜像。
在同一主机下搭建容器应用栈的环境,只需要完成容器互联来实现容器之间的通信。

docker主机搭建mysql集群详见
https://www.cnblogs.com/zhenghongxin/p/9228101.html

猜你喜欢

转载自blog.csdn.net/inxes_/article/details/82466169