程式扎記: [ 常見問題 ] How to connect to Docker API from another machine?

標籤

2015年6月22日 星期一

[ 常見問題 ] How to connect to Docker API from another machine?

Source From Here
Question
I'm trying to use the Docker API to connect to docker daemon from another machine. I am able to do this command successfully:
# docker -H=tcp://127.0.0.1:4243 images

But NOT when I use the real IP address:
# docker -H=tcp://192.168.2.123:4243 images
2013/08/04 01:35:53 dial tcp 192.168.2.123:4243: connection refused

Why can't I connect when using a non-local IP?

How-To
Came across a similar issue, one thing I don't see mentioned here is you need to start docker to listen to both the network and a unix socket. All regular docker (command-line) commands on the host assume the socket:
// -H, --host=[] Daemon socket(s) to connect to
// -d, --daemon=false Enable daemon mode
# docker -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock -d &

will start docker listening to any ip address on your host, as well as the typical unix socket.

Supplement
Docker Doc - Docker Command Line - daemon
The Docker daemon is the persistent process that manages containers. Docker uses the same binary for both the daemon and client. To run the daemon you provide the -d flag. To run the daemon with debug output, use docker -d -D...


沒有留言:

張貼留言

網誌存檔

關於我自己

我的相片
Where there is a will, there is a way!