title: Permission denied in Docker build
body: <p>I have following docker file</p>
  
  <pre><code>FROM something.com/..../lrh7:latest
  RUN whoami
  SHELL ["/usr/sbin", "-c"]
  RUN /usr/sbin/groupadd -g 1000 AB_DOCKER_SETUP_GROUP
  </code></pre>
  
  <p>when I do a docker build then it fails stating permission denied </p>
  
  <pre><code>container_linux.go:247: starting container process caused "exec: \"/usr/sbin\": permission denied"
  </code></pre>
  
  <p>but when I change </p>
  
  <pre><code>RUN /usr/sbin/groupadd -g 1000 AB_DOCKER_SETUP_GROUP
  </code></pre>
  
  <p>to</p>
  
  <pre><code>CMD ["su", "-" ,"groupadd", "-g", "1000", "AB_DOCKER_SETUP_GRO"]
  </code></pre>
  
  <p>then docker build succeed. Output of whoami is ROOT which means I am running as root, even after that I have to specify sudo explicitly to add group.</p>
  
  <p>Running </p>
  
  <pre><code>RUN su - /usr/sbin/groupadd -g 1000 AB_DOCKER_SETUP_GROUP # sudo/su both fails
  </code></pre>
  
  <p>also fails with permission denied. I have no clarity whats happening behind the scene.</p>