Setting insecure registry in docker-in-docker image docker daemon
<p>Attempting to add an insercure docker registry to a dind image that I run in a concourse task:</p>

<p>I tried beginning my task by running: </p>

<pre><code>export DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=${INSECURE_REG}"
</code></pre>

<p>and tried spinning up the daemon and compose:</p>

<pre><code>docker daemon --insecure-registry=${INSECURE_REG} &amp;
docker-compose up
</code></pre>

<p><strong>However the task errors: server gave http response to https client, and no such image</strong></p>

<p>The whole task looks like this (basically it is a shell script executed in the dind container that ends with a docker-compose):</p>

<pre><code># Connect to insecure docker registry:
export DOCKER_OPTS="$DOCKER_OPTS --insecure-registry=${INSECURE_REG}"

# Install docker-compose:
apk add --no-cache py-pip curl
pip install docker-compose

# Verify docker registry:
curl http://${INSECURE_REG}/v2/_catalog #curl does return the expected json

sanitize_cgroups() {
  mkdir -p /sys/fs/cgroup
  mountpoint -q /sys/fs/cgroup || \
    mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup

  mount -o remount,rw /sys/fs/cgroup

  sed -e 1d /proc/cgroups | while read sys hierarchy num enabled; do
    if [ "$enabled" != "1" ]; then
      # subsystem disabled; skip
      continue
    fi

    grouping="$(cat /proc/self/cgroup | cut -d: -f2 | grep "\\&lt;$sys\\&gt;")"
    if [ -z "$grouping" ]; then
      # subsystem not mounted anywhere; mount it on its own
      grouping="$sys"
    fi

    mountpoint="/sys/fs/cgroup/$grouping"

    mkdir -p "$mountpoint"

    # clear out existing mount to make sure new one is read-write
    if mountpoint -q "$mountpoint"; then
      umount "$mountpoint"
    fi

    mount -n -t cgroup -o "$grouping" cgroup "$mountpoint"

    if [ "$grouping" != "$sys" ]; then
      if [ -L "/sys/fs/cgroup/$sys" ]; then
        rm "/sys/fs/cgroup/$sys"
      fi

      ln -s "$mountpoint" "/sys/fs/cgroup/$sys"
    fi
  done
}

# https://github.com/concourse/concourse/issues/324
sanitize_cgroups


# Spin up the stack as described in docker-compose:
docker daemon --insecure-registry=${INSECURE_REG} &amp;
docker-compose up
</code></pre>