设置docker api - 修改docker.conf

时间:2016-04-08 13:17:32

标签: docker docker-api

我找到了video关于通过Packt发布设置docker remote api的问题。 在视频中,我们被告知要通过将"-H tcp://127.0.0.1:4243 -H unix:///var/run/docker/sock"添加到DOCKER_OPTS=来更改/etc/init/docker.conf文件。然后我们必须重新启动docker才能使更改生效。 但是在我做完所有这些之后,我仍然无法在该端口卷曲localhost。这样做会返回:

vagrant@vagrant-ubuntu-trusty-64:~$ curl localhost:4243/_ping
curl: (7) Failed to connect to localhost port 4243: Connection refused 

我是码头工人的新相对论,如果有人能帮助我,我会非常感激。

编辑: docker.conf

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

pre-start script
        # see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
        if grep -v '^#' /etc/fstab | grep -q cgroup \
                || [ ! -e /proc/cgroups ] \
                || [ ! -d /sys/fs/cgroup ]; then
                exit 0
        fi
        if ! mountpoint -q /sys/fs/cgroup; then
                mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
        fi
        (
                cd /sys/fs/cgroup
                for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
                        mkdir -p $sys
                        if ! mountpoint -q $sys; then
                                if ! mount -n -t cgroup -o $sys cgroup $sys; then
                                        rmdir $sys || true
                                fi
                        fi
                done
        )
end script

script
        # modify these in /etc/default/$UPSTART_JOB (/etc/default/docker)
        DOCKER=/usr/bin/$UPSTART_JOB
        DOCKER_OPTS="-H tcp://127.0.0.1:4243 -H unix:///var/run/docker.sock"
        if [ -f /etc/default/$UPSTART_JOB ]; then
                . /etc/default/$UPSTART_JOB
        fi
        exec "$DOCKER" daemon $DOCKER_OPTS
end script

# Don't emit "started" event until docker.sock is ready.
# See https://github.com/docker/docker/issues/6647
post-start script
        DOCKER_OPTS=
        if [ -f /etc/default/$UPSTART_JOB ]; then
"/etc/init/docker.conf" 60L, 1582C

EDIT2:ps aux | grep docker

的输出
vagrant@vagrant-ubuntu-trusty-64:~$ ps aux | grep docker
root       858  0.2  4.2 401836 21504 ?        Ssl  06:12   0:00 /usr/bin/docker daemon --insecure-registry 11.22.33.44
:5000
vagrant   1694  0.0  0.1  10460   936 pts/0    S+   06:15   0:00 grep --color=auto docker

1 个答案:

答案 0 :(得分:0)

问题

根据ps aux|grep docker的输出,可以注意到守护进程启动的选项与docker.conf文件中的选项不匹配。然后使用另一个文件启动docker守护程序服务。

解决方案

要解决此问题,请跟踪包含可能"--insecure-registry 11.22.33.44:5000/etc/default/docker/etc/init/docker.conf或idk-where-else的选项/etc/systemd/system/docker.service的文件,并相应地对其进行修改有所需的选择。

然后重启守护进程,你就好了!