上周我努力让docker remote api
工作。因为它在VM上运行,所以我从那时起就没有重新启动我的VM。今天我终于重新启动了我的虚拟机,它不再工作了(docker和docker-compose工作正常,但不是docker remote api
)。我的docker init文件如下所示:/etc/init/docker.conf
。
description "Docker daemon"
start on filesystem and started lxc-net
stop on runlevel [!2345]
respawn
script
/usr/bin/docker -H tcp://0.0.0.0:4243 -d
end script
# description "Docker daemon"
# start on (filesystem and net-device-up IFACE!=lo)
# stop on runlevel [!2345]
# limit nofile 524288 1048576
# limit nproc 524288 1048576
respawn
kill timeout 20
.....
.....
上次我在此处设置了设置this
我尝试nmap
查看port 4243
是否已打开。
ubuntu@ubuntu:~$ nmap 0.0.0.0 -p-
Starting Nmap 7.01 ( https://nmap.org ) at 2016-10-12 23:49 CEST
Nmap scan report for 0.0.0.0
Host is up (0.000046s latency).
Not shown: 65531 closed ports
PORT STATE SERVICE
22/tcp open ssh
43978/tcp open unknown
44672/tcp open unknown
60366/tcp open unknown
Nmap done: 1 IP address (1 host up) scanned in 1.11 seconds
如您所见,端口4232未打开。
我跑的时候:
ubuntu@ubuntu:~$ echo -e "GET /images/json HTTP/1.0\r\n" | nc -U
This is nc from the netcat-openbsd package. An alternative nc is available
in the netcat-traditional package.
usage: nc [-46bCDdhjklnrStUuvZz] [-I length] [-i interval] [-O length]
[-P proxy_username] [-p source_port] [-q seconds] [-s source]
[-T toskeyword] [-V rtable] [-w timeout] [-X proxy_protocol]
[-x proxy_address[:port]] [destination] [port]
我也跑了这个:
ubuntu@ubuntu:~$ sudo docker -H=tcp://0.0.0.0:4243 -d
flag provided but not defined: -d
See 'docker --help'.
我多次重新启动计算机并尝试了很多事情但没有成功。 我已经有一个名为docker的组,我的用户位于:
ubuntu@ubuntu:~$ groups $USER
ubuntu : ubuntu adm cdrom sudo dip plugdev lpadmin sambashare docker
请告诉我有什么问题。
答案 0 :(得分:3)
您的启动脚本包含无效命令:
/usr/bin/docker -H tcp://0.0.0.0:4243 -d
相反,你需要这样的东西:
/usr/bin/docker daemon -H tcp://0.0.0.0:4243
从1.12开始,现在是这样(但docker daemon
仍然有效):
/usr/bin/dockerd -H tcp://0.0.0.0:4243
请注意,这是打开一个端口,可以为您的docker主机提供远程root访问权限,而无需任何密码。
任何想要接管您的计算机的人都可以运行docker run -v /:/target -H your.ip:4243 busybox /bin/sh
来获取一个root shell,并将您的文件系统安装在/ target。如果您想保护主持人,请按this guide to setting up TLS certificates。
答案 1 :(得分:0)
我终于找到了www.ivankrizsan.se,现在正在寻找。感谢这个家伙(或女孩);)。 这个设置适用于ubuntu 16.04。以下是该怎么做:
/lib/systemd/system/docker.service
并将行ExecStart=/usr/bin/dockerd -H fd://
替换为
ExecStart=/usr/bin/docker daemon -H fd:// -H tcp://0.0.0.0:4243
sudo service docker restart
curl http://localhost:4243/version
结果:您应该看到类似的内容:
{"Version":"1.11.0","ApiVersion":"1.23","GitCommit":"4dc5990","GoVersion" "go1.5.4","Os":"linux","Arch":"amd64","KernelVersion":"4.4.0-22-generic","BuildTime":"2016-04-13T18:38:59.968579007+00:00"}
注意: 仍然知道0.0.0.0不利于安全性,为了更高的安全性,您应该使用127.0.0.1