title: Docker exec in bash script
body: <p>I'm creating dynamically docker containers via bash script: </p>
  
  <pre><code>while getopts ":s:d:h" opt; do
      case $opt in
          s)
              for i in $(seq $2 $END); 
                  do 
                      docker run -dit --name=app_client_$i -d app:client
                      docker exec -d app_client_$i $app_start
              done
              ;;
  ...
  </code></pre>
  
  <p>The docker container starts fine, but the <code>docker exec</code> command caused problems. When I try (without the <code>-d</code>):</p>
  
  <pre><code>docker exec app_client_$i $app_start
  </code></pre>
  
  <p>The application inside the docker container starts fine - but I'm attached to this docker container. I want to start the app inside the docker container in the background, so I use the <code>-d</code> parameter:</p>
  
  <pre><code>docker exec -d app_client_$i $app_start
  </code></pre>
  
  <p>With that the app doesn't start inside the docker container. What I am missing?</p>