Reputation: 619
I used this official guide to install Docker Containers on Windows. Everything looks good and I can run IIS on Windows Containers now.
However, I don't see it anywhere and have no idea on how to "Enable Rest API" for it. How can I do this?
Upvotes: 3
Views: 3668
Reputation: 25942
Just came across the same issue, and discovered the REST API was already enabled!
set API=https://192.168.99.100:2376/v1.24/containers/json?all=1
set CERT=C:\Users\Nick\.docker\machine\machines\default
curl --cert "%CERT%/cert.pem" --cacert "%CERT%/ca.pem" --key "%CERT%/key.pem" "%API%"
Here's how I accessed the REST API from the windows cmd
.
default
> 192.168.99.100:2376
)/v1.24/containers/json?all=1
)C:\Users\Nick>docker --version
Docker version 18.03.0-ce, build 0520e24302
C:\Users\Nick>docker-machine ls
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS
default - virtualbox Running tcp://192.168.99.100:2376 v18.03.0-ce
C:\Users\Nick>set DOCKER_CA=C:\Users\Nick\.docker\machine\machines\default
C:\Users\Nick>curl --cert "%DOCKER_CA%/cert.pem" --cacert "%DOCKER_CA%/ca.pem" --key "%DOCKER_CA%/key.pem" https://192.168.99.100:2376/v1.24/containers/json?all=1
[]
For those that are interested...
Upvotes: 3
Reputation: 20487
(Posted on behalf of the OP).
Finally, I found how to enable Remote API of Docker Containers on Windows. The key point is file daemon.json which place in C:\ProgramData\docker\config.
In the guide linked in the question, the author only mention that we should place in it something like:
{"hosts": ["tcp://0.0.0.0:2376", "npipe://"]}
But when I try to add this to daemon.json, my daemon don't work on CLI. At last, I reverse the order of array like
{"hosts": ["npipe://", "tcp://0.0.0.0:2376"]}
My docker will work well in both CLI & Remote API. Good experience with Windows Docker and thanks for your attention!
Upvotes: 2