1

I found a video about setting up the docker remote api by Packt publishing. In the video we are told to change the /etc/init/docker.conf file by adding "-H tcp://127.0.0.1:4243 -H unix:///var/run/docker/sock" to DOCKER_OPTS=. Then we have to restart docker for the changes to take effect. However after I do all that, I still can't curl localhost at that port. Doing so returns:

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

I'm relativity new to docker, if somebody could help me out here I'd be very grateful.

Edit: 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: Output of 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
Lukasz
  • 2,257
  • 3
  • 26
  • 44
  • Can you show the whole line of the conf file please? – Auzias Apr 08 '16 at 17:33
  • @Auzias I can do you one better. I added the whole config file. There is only one line where I added the option so there should be no confusion. – Lukasz Apr 08 '16 at 22:21
  • What does `ps aux|grep docker` output look like? – Auzias Apr 11 '16 at 06:08
  • @Auzias just added it. – Lukasz Apr 11 '16 at 06:20
  • 1
    The option are not used to start the daemon. Are you using `systemd` or the `service` command line? Try to restart the daemon. Try also to find out if other conf file of Docker are present (`/etc/systemd/system/docker.service` for `systemd`, `/etc/init/docker.conf` for `service`, or other) – Auzias Apr 11 '16 at 08:45
  • @Auzias There was another docker configuration file I changed and forgot about `/etc/default/docker` where I set `DOCKER_OPTS=DOCKER_OPTS="--insecure-registry 11.22.33.44:5000"`. I only needed to add the new option there after a comma and it works. However now I have another question. Can I edit DOCKER_OPTS only in one place? What is DOCKER_OPTS? It would be nice to append to DOCKER_OPTS like to an environment variable. Do you know how to do that? – Lukasz Apr 11 '16 at 10:58
  • `DOCKER_OPTS` is the options you want your daemon docker running with. You are expected to use a single place to modify it. It is not a good idea to use it as and env var as it is supposed to be immutable. – Auzias Apr 11 '16 at 11:20
  • @Auzias I can live with that, just thought it would be convenient. Would you like to condense this comments into an answer, or should I do it? – Lukasz Apr 11 '16 at 11:25

1 Answers1

1

The problem

According to the output of ps aux|grep docker it can be noticed that the options the daemon is started with do not match the ones in the docker.conf file. Another file is then used to start the docker daemon service.

Solution

To solve this, track down the file that contains the option "--insecure-registry 11.22.33.44:5000 that may either /etc/default/docker or /etc/init/docker.conf or /etc/systemd/system/docker.service or idk-where-else and modify it accordingly with the needed options.

Then restart the daemon and you're good to go !

Auzias
  • 3,638
  • 14
  • 36