title: invalid header field value "oci runtime error while running docker image
body: <p>I have below Dockerfile for zookeeper setup and I have built docker image for that.</p>
  
  <pre><code>FROM openjdk:8-jre-alpine
  
  # Install required packages
  RUN apk add --no-cache \
      bash \
      su-exec
  
  ENV ZOO_USER=zookeeper \
      ZOO_CONF_DIR=/conf \
      ZOO_DATA_DIR=/data \
      ZOO_DATA_LOG_DIR=/datalog \
      ZOO_PORT=2181 \
      ZOO_TICK_TIME=2000 \
      ZOO_INIT_LIMIT=5 \
      ZOO_SYNC_LIMIT=2
  
  # Add a user and make dirs
  RUN set -x \
      &amp;&amp; adduser -D "$ZOO_USER" \
      &amp;&amp; mkdir -p "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR" \
      &amp;&amp; chown "$ZOO_USER:$ZOO_USER" "$ZOO_DATA_LOG_DIR" "$ZOO_DATA_DIR" "$ZOO_CONF_DIR"
  
  ARG GPG_KEY=C823E3E5B12AF29C67F81976F5CECB3CB5E9BD2D
  ARG DISTRO_NAME=zookeeper-3.4.9
  
  # Download Apache Zookeeper, verify its PGP signature, untar and clean up
  RUN set -x \
      &amp;&amp; apk add --no-cache --virtual .build-deps \
          gnupg \
      &amp;&amp; wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz" \
      &amp;&amp; wget -q "http://www.apache.org/dist/zookeeper/$DISTRO_NAME/$DISTRO_NAME.tar.gz.asc" \
      &amp;&amp; export GNUPGHOME="$(mktemp -d)" \
      &amp;&amp; gpg --keyserver ha.pool.sks-keyservers.net --recv-key "$GPG_KEY" \
      &amp;&amp; gpg --batch --verify "$DISTRO_NAME.tar.gz.asc" "$DISTRO_NAME.tar.gz" \
      &amp;&amp; tar -xzf "$DISTRO_NAME.tar.gz" \
      &amp;&amp; mv "$DISTRO_NAME/conf/"* "$ZOO_CONF_DIR" \
      &amp;&amp; rm -r "$GNUPGHOME" "$DISTRO_NAME.tar.gz" "$DISTRO_NAME.tar.gz.asc" \
      &amp;&amp; apk del .build-deps
  
  WORKDIR $DISTRO_NAME
  VOLUME ["$ZOO_DATA_DIR", "$ZOO_DATA_LOG_DIR"]
  
  EXPOSE $ZOO_PORT 2888 3888
  
  ENV PATH=$PATH:/$DISTRO_NAME/bin \
      ZOOCFGDIR=$ZOO_CONF_DIR
  
  COPY docker-entrypoint.sh /
  ENTRYPOINT ["/docker-entrypoint.sh"]
  CMD ["zkServer.sh", "start-foreground"]
  </code></pre>
  
  <p>I build it like this:</p>
  
  <pre><code>root@duo4:/home/david/zookeeper-docker# docker build -t david/zookeeper:3.4.9 .
  </code></pre>
  
  <p>When I run the zookeeper instance, I am getting this error:</p>
  
  <pre><code>root@duo4:/home/david/zookeeper-docker# docker run --name zookeeper --restart always -d david/zookeeper:3.4.9
  24a282f2d04f1b638820a63a2037f618621d315d8c1cdb62aed609426bb19045
  docker: Error response from daemon: invalid header field value "oci runtime error: container_linux.go:247: starting container process caused \"exec: \\\"/docker-entrypoint.sh\\\": permission denied\"\n".
  </code></pre>
  
  <p>What is wrong here? I have all my files inside <code>zookeeper-docker</code> directory. Also I gave <code>chmod +x</code> persmission to <code>docker-entrypoint.sh</code> in my current directory.</p>
  
  <p>Below is the content of <code>docker-entrypoint.sh</code></p>
  
  <pre><code>#!/bin/bash
  
  set -e
  
  # Allow the container to be started with `--user`
  if [ "$1" = 'zkServer.sh' -a "$(id -u)" = '0' ]; then
      chown -R "$ZOO_USER" "$ZOO_DATA_DIR" "$ZOO_DATA_LOG_DIR"
      exec su-exec "$ZOO_USER" "$0" "$@"
  fi
  
  # Generate the config only if it doesn't exist
  if [ ! -f "$ZOO_CONF_DIR/zoo.cfg" ]; then
      CONFIG="$ZOO_CONF_DIR/zoo.cfg"
  
      echo "clientPort=$ZOO_PORT" &gt;&gt; "$CONFIG"
      echo "dataDir=$ZOO_DATA_DIR" &gt;&gt; "$CONFIG"
      echo "dataLogDir=$ZOO_DATA_LOG_DIR" &gt;&gt; "$CONFIG"
  
      echo "tickTime=$ZOO_TICK_TIME" &gt;&gt; "$CONFIG"
      echo "initLimit=$ZOO_INIT_LIMIT" &gt;&gt; "$CONFIG"
      echo "syncLimit=$ZOO_SYNC_LIMIT" &gt;&gt; "$CONFIG"
  
      for server in $ZOO_SERVERS; do
          echo "$server" &gt;&gt; "$CONFIG"
      done
  fi
  
  # Write myid only if it doesn't exist
  if [ ! -f "$ZOO_DATA_DIR/myid" ]; then
      echo "${ZOO_MY_ID:-1}" &gt; "$ZOO_DATA_DIR/myid"
  fi
  
  exec "$@"
  </code></pre>
  
  <p>Below is the output:</p>
  
  <pre><code>root@duo4:/home/david/zookeeper-docker# docker run --name zookeeper --entrypoint "/usr/bin/env" david/zookeeper:3.4.9 -- ls -al /
  total 80
  drwxr-xr-x   47 root     root          4096 Nov  7 19:09 .
  drwxr-xr-x   47 root     root          4096 Nov  7 19:09 ..
  -rwxr-xr-x    1 root     root             0 Nov  7 19:09 .dockerenv
  drwxr-xr-x    2 root     root          4096 Nov  7 17:44 bin
  drwxr-xr-x    2 zookeepe zookeepe      4096 Nov  7 17:45 conf
  drwxr-xr-x    2 zookeepe zookeepe      4096 Nov  7 19:09 data
  drwxr-xr-x    2 zookeepe zookeepe      4096 Nov  7 19:09 datalog
  drwxr-xr-x    5 root     root           360 Nov  7 19:09 dev
  -rw-r--r--    1 root     root           873 Nov  6 01:36 docker-entrypoint.sh
  drwxr-xr-x   22 root     root          4096 Nov  7 19:09 etc
  drwxr-xr-x    3 root     root          4096 Nov  7 17:44 home
  drwxr-xr-x    8 root     root          4096 Nov  7 17:45 lib
  lrwxrwxrwx    1 root     root            12 Oct 18 18:58 linuxrc -&gt; /bin/busybox
  drwxr-xr-x    5 root     root          4096 Oct 18 18:58 media
  drwxr-xr-x    2 root     root          4096 Oct 18 18:58 mnt
  dr-xr-xr-x  141 root     root             0 Nov  7 19:09 proc
  drwx------    2 root     root          4096 Oct 18 18:58 root
  drwxr-xr-x    2 root     root          4096 Oct 18 18:58 run
  drwxr-xr-x    2 root     root          4096 Nov  7 17:44 sbin
  drwxr-xr-x    2 root     root          4096 Oct 18 18:58 srv
  dr-xr-xr-x   13 root     root             0 Nov  7 19:09 sys
  drwxrwxrwt    2 root     root          4096 Nov  7 17:45 tmp
  drwxr-xr-x   19 root     root          4096 Nov  7 17:45 usr
  drwxr-xr-x   15 root     root          4096 Nov  7 17:44 var
  drwxr-xr-x   10 1001     1001          4096 Nov  7 17:45 zookeeper-3.4.9
  </code></pre>