如何在Windows上启用Docker远程API [英] How to enable the Docker Remote API on Windows
问题描述
我正在尝试在Windows 10主机上使用Docker远程API.我正在使用Chrome的Postman扩展程序,以查看是否可以从docker远程api的端点获取结果.这是我尝试过的端点:
I am trying to use the Docker Remote API on a Windows 10 host machine. I am using Chrome's Postman extension to see if I can get results from the docker remote api's endpoints. Here are the endpoints that I've tried:
GET http://192.168.99.100:4243/images/json
GET http://192.168.99.100:2376/images/json
两个都返回了Connection to server 192.168.99.100 failed (The server is not responding)
经过几次搜索,我发现Windows上默认未启用Docker远程API.大多数指南都是针对Ubuntu的,但是我发现了这个特殊的
After a few searches I found out that the Docker Remote API is not enabled by default on Windows. Most of the guides are for Ubuntu but I have found this particular one for Windows.
这些是我在计算机上执行的步骤
These are the steps that I performed on my machine
- docker-machine ssh
- cd/var/lib/boot2docker
- sudo vi配置文件
- 将
DOCKER_HOST='H tcp://0.0.0.2376'
更改为DOCKER_HOST='H tcp://0.0.0.2375'
- 将
DOCKER_TLS=auto
更改为DOCKER_TLS=no
- export DOCKER_HOST ='-H tcp://0.0.0.2375'
- 导出DOCKER_TLS_VERIFY = 0
- env | grep DOCKER
- docker-machine restart
- docker-machine env
- docker-machine regenerate-certs
- docker-machine ssh
- cd /var/lib/boot2docker
- sudo vi profile
- Change
DOCKER_HOST='H tcp://0.0.0.2376'
toDOCKER_HOST='H tcp://0.0.0.2375'
- change
DOCKER_TLS=auto
toDOCKER_TLS=no
- export DOCKER_HOST='-H tcp://0.0.0.2375'
- export DOCKER_TLS_VERIFY=0
- env | grep DOCKER
- docker-machine restart
- docker-machine env
- docker-machine regenerate-certs
执行上述步骤后,我确实在Postman上再次尝试了端点,但仍然得到相同的结果.
After performing the steps above, I did try again the endpoints on Postman but I still get the same result.
如果我错过了一步,您能给点帮助吗?还是我在轨道上?
Can you perhaps give a little help if I have missed a step? Or am I on track?
还要回答我的一些疑问.
Also, to answer some of my queries.
- 是Windows 2375和Linux 2243的docker远程api端口吗?
- 对于Windows是DOCKER_HOST,对于Linux是DOCKER_OPTS?
推荐答案
将您的docker切换到windows container
Switch your docker to windows container
转到C:\ProgramData\Docker\config
在deamon.json
文件
添加"hosts": ["tcp://0.0.0.0:2376", "npipe://"]
重新启动docker.
restart docker.
给出命令:docker -H tcp://0.0.0.0:2376 ps
这篇关于如何在Windows上启用Docker远程API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!