title: How to run a CMD and open Bash when running a docker container?
body: <p>I am having a rough time trying to figure this out.</p>
  
  <p>So I have a dockerfile based on an Ubuntu image.  At the end of my dockerfile I have:</p>
  
  <pre><code>CMD django-admin startproject $PROJECTNAME
  </code></pre>
  
  <p>I was told in a previous post that the base Ubuntu image has a CMD to run /bin/bash so my command is actually overwriting this (not sure if this is relevant or not).</p>
  
  <p>The problem I'm encountering is if I run:</p>
  
  <pre><code>docker run -i -t &lt;containerid&gt; 
  </code></pre>
  
  <p>Nothing happens..  docker ps shows no containers are running</p>
  
  <p>But if I run:</p>
  
  <pre><code>docker run -i -t &lt;containerid&gt; /bin/bash
  </code></pre>
  
  <p>The container starts running, I am in the shell, and docker ps shows that this container is running.  Everything works as expected, but my django project is not there and my understanding is that running /bin/bash overrides the CMD in the dockerfile, which means django-admin startproject never gets run.</p>
  
  <p>From inside the container, I can run django-admin startproject $projectname and  it creates the project with no issues, which tells me django and all its dependencies are installed, and my environment variables are being registered.</p>
  
  <p>However, I still suspect that there maybe is an issue with my CMD in my dockerfile and I don't know where to go from here.</p>
  
  <p>With my provided dockerfile, if I do not run the container with /bin/bash, the container will not run.</p>
  
  <p>Output of docker images:</p>
  
  <pre><code>REPOSITORY          TAG                 IMAGE ID            CREATED              SIZE
  &lt;none&gt;              &lt;none&gt;              cbec557d6362        About a minute ago   579 MB
  &lt;none&gt;              &lt;none&gt;              6919c19b159a        16 hours ago 
  </code></pre>
  
  <p>docker run:</p>
  
  <pre><code>docker run -i -t cbec557d6362
  </code></pre>