title: How to use sudo inside a docker container?
body: <p>Normally, docker containers are run using the user <strong>root</strong>. I'd like to use a different user, which is no problem using docker's USER directive. But this user should be able to use <strong>sudo</strong> inside the container. This command is missing.</p>
  
  <p>Here's a simple Dockerfile for this purpose:</p>
  
  <pre><code>FROM ubuntu:12.04
  
  RUN useradd docker &amp;&amp; echo "docker:docker" | chpasswd
  RUN mkdir -p /home/docker &amp;&amp; chown -R docker:docker /home/docker
  
  USER docker
  CMD /bin/bash
  </code></pre>
  
  <p>Running this container, I get logged in with user 'docker'. When I try to use sudo, the command isn't found. So I tried to install the <em>sudo</em> package inside my Dockerfile using </p>
  
  <pre><code>RUN apt-get install sudo
  </code></pre>
  
  <p>This results in <em>Unable to locate package sudo</em></p>