# 安装依赖包
yum install -y yum-utils device-mapper-persistent-data lvm2 # 添加Docker软件包源
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo # 安装Docker CE
yum install -y docker-ce
# 启动Docker服务并设置开机启动
systemctl start docker
systemctl enable docker
官方文档:https://docs.docker.com/install/linux/docker-ce/centos/
查看主机docker信息
# docker info
Containers: 7
Running: 3
Paused: 0
Stopped: 4
Images: 2
Server Version: 18.09.6 ##版本
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 local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: bb71b10fd8f58240ca47fbb579b9d1028eea7c84
runc version: 2b18fe1d885ee5083ef9f0838fee39b62d653e30
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-957.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 3.701GiB
Name: localhost.localdomain
ID: T4QU:IVGR:GWMX:A4G6:KK7R:635D:KNLW:4GW4:LSZG:QE7N:X42X:ENP7
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
Registry Mirrors:
http://f1361db2.m.daocloud.io/ ##默认镜像仓库地址
Live Restore Enabled: false
Product License: Community Engine
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
# docker version
Client:
Version: 18.09.6
API version: 1.39
Go version: go1.10.8
Git commit: 481bc77156
Built: Sat May 4 02:34:58 2019
OS/Arch: linux/amd64
Experimental: false
Server: Docker Engine - Community
Engine:
Version: 18.09.6
API version: 1.39 (minimum version 1.12)
Go version: go1.10.8
Git commit: 481bc77
Built: Sat May 4 02:02:43 2019
OS/Arch: linux/amd64
Experimental: false
创建一个容器:
# docker run -it nginx
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
743f2d6c1f65: Already exists
6bfc4ec4420a: Already exists
688a776db95f: Already exists
Digest: sha256:23b4dcdf0d34d4a129755fc6f52e1c6e23bb34ea011b315d87e193033bcd1b68
Status: Downloaded newer image for nginx:latest
##查看主机的容器:
# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
916b2fd08347 nginx "nginx -g 'daemon of…" About a minute ago Up About a minute 80/tcp frosty_bassi
查看容器详细信息:
# docker inspect 916b2fd08347
进入容器:
# docker exec -it 916b2fd08347 bash
访问刚刚启动的容器的nginx:
# curl 172.17.0.2










网友评论