前提:
系统centos 7
docker version 1.10.3
使用systemd启动docker
访问方式:
修改/usr/lib/systemd/system/docker.service中的ExecStart,添加host " -H tcp://0.0.0.0:1234 "
ExecStart=/usr/bin/docker daemon $DOCKER_OPTS -H tcp://0.0.0.0:1234
执行systemctl --system daemon-reload, 将docker守护进程绑定到网络接口1234上。
(我机器执行上述命令没起作用,我就重启了docker : systemctl restart docker.service)
这时候会看到1234端口被docker进程绑定了。
[root@node888 system]# ss -anp | grep 1234
tcp LISTEN 0 128 :::1234 :::* users:(("docker",8694,6))
查看docker信息,验证绑定情况
docker -H localhost:1234 info
可以看到
Containers: 49
Running: 1
Paused: 0
Stopped: 48
Images: 6
Server Version: 1.10.3
Storage Driver: devicemapper
Pool Name: docker-253:0-202045413-pool
Pool Blocksize: 65.54 kB
Base Device Size: 10.74 GB
Backing Filesystem: xfs
Data file: /dev/loop0
Metadata file: /dev/loop1
Data Space Used: 4.555 GB
Data Space Total: 107.4 GB
Data Space Available: 2.347 GB
Metadata Space Used: 10.02 MB
Metadata Space Total: 2.147 GB
Metadata Space Available: 2.137 GB
Udev Sync Supported: false
Deferred Removal Enabled: false
Deferred Deletion Enabled: false
Deferred Deleted Device Count: 0
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
WARNING: Usage of loopback devices is strongly discouraged for production use. Either use `--storage-opt dm.thinpooldev` or use `--storage-opt dm.no_warn_on_loop_devices=true` to suppress this warning.
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
Library Version: 1.02.82 (2013-10-04)
Execution Driver: native-0.2
Logging Driver: json-file
Plugins:
Volume: local
Network: null host bridge
Kernel Version: 3.10.0-229.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 15.52 GiB
Name: tw-node1247
ID: 757V:3H6N:ACAT:OJJJ:S353:QAQV:63HH:DWWR:KVQD:PFEQ:TGST:LUZ2
Debug mode (server): true
File Descriptors: 20
Goroutines: 35
System Time: 2017-03-05T20:29:46.906849392+08:00
EventsListeners: 0
Init SHA1:
Init Path: /usr/bin/docker
Docker Root Dir: /var/lib/docker
Username: lixiaolun
Registry: https://index.docker.io/v1/
或者使用curl http://localhost:1234/info
查看image
curl http://localhost:2345/images/json | python -mjson.tool