Docker Remote API 初步尝试
1、首先是安装 docker 这里就不说了2、查看一下 docker api的版本>sudo docker versionClient: Version: 1.10.2 API version: 1.22 Go version: go1.5.3 Git commit: c3959b1 Built: Mon Feb 22 21
1、首先是安装 docker 这里就不说了
2、查看一下 docker api的版本
>sudo docker version
Client:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 21:37:01 2016
OS/Arch: linux/amd64
Server:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 21:37:01 2016
OS/Arch: linux/amd64
查看对应的文档
https://docs.docker.com/engine/reference/api/docker_remote_api_v1.22/
默认情况下,Docker daemon监听unix://var/run/docker.sock,
并且必须有root权限用来操作daemon,不然报 Cannot connect to the Docker daemon. Is the docker daemon running on this host?
为了使用Docker REST API,可以先停止docker服务,然后在启动的时候加-H标记开启远程访问:
service docker stop
docker -d -H unix:///var/run/docker.sock -H 0.0.0.0:5555
为了使配置永久生效,在Ubuntu环境下修改其配置文件 /etc/default/docker,
加入 DOCKER_OPTS="-H=unix:///var/run/docker.sock -H=0.0.0.0:5555"
然后重启 docker服务
>sudo service docker restart
docker stop/waiting
docker start/running, process 14768
测试一下 是否开启成功
curl http://127.0.0.1/version
{"Version":"1.10.2","ApiVersion":"1.22","GitCommit":"c3959b1","GoVersion":"go1.5.3","Os":"linux","Arch":"amd64","KernelVersion":"3.16.0-30-generic","BuildTime":"2016-02-22T21:37:01.910365059+00:00"}
这步成功了,下面就是 根据官方文档各种玩了
更多推荐
所有评论(0)