docker定义
百度百科定义:
Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的容器中,然后发布到任何流行的 Linux 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。
一个完整的Docker有以下几个部分组成:
1.dockerClient客户端
2.Docker Daemon守护进程
3.Docker Image镜像
4.DockerContainer容器
docker安装
具体详情参照:CentOS下安装docker
设置开机启动
sudo systemctl enable docker
有时候默认安装磁盘不够了,我们需要改变镜像默认安装路径(下文加出部分)
[root@localhost yum.repos.d]# docker info
Containers: 1
Running: 0
Paused: 0
Stopped: 1
Images: 1
Server Version: 18.06.1-ce
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 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: 976.3MiB
Name: localhost
ID: UE5G:UQRI:MJ4K:UGGT:7M2T:XAMV:IQKQ:6FND:JOTV:ZYDV:47WB:HRFO
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
修改如下内容
sudo vim /usr/lib/systemd/system/docker.service
文本内容:ExecStart=/usr/bin/dockerd后面添加如下内容:
–graph /docker/images/
记得建好文件夹 ,然后重载配置文件
sudo systemctl daemon-reload
接着重启服务
sudo systemctl restart docker.service
通常我们将docker服务接口暴露出去用来远程构建镜像,用来自动部署服务,可以使用下面方式:
接着在ExecStart=/usr/bin/dockerd后面添加一下内容
-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock
然后重载配置文件,重启服务。
测试方式:curl http://127.0.0.1:2375/info
如果出现包含ID等json串则配置生效。