title: Docker - Kill a detached docker with Ctrl+C inside container
body: <p>I have a <code>docker-compose.yml</code> file which I start in detached mode:</p>
  <p><code>docker-compose up -d #Container starts in background</code></p>
  <p>After that I start a few other services inside the container and then I enter the container's bash:</p>
  <pre><code>docker exec -it web bash  -c 'start_other_background_services.sh; bash;'
  </code></pre>
  <p>If I <code>Ctrl+C</code> while being inside the container's bash, the bash exits, but the docker container is still running since it was launched in detached mode.</p>
  <p>My question is, while being in container's bash, is it possible to stop the already running detached container, once <code>Ctrl+C</code> is pressed?</p>
  <p>I've tried catching the signal but it doesn't seem to work:</p>
  <pre><code>docker exec -it web bash  -c 'trap &quot;echo ttteeeeeeeeeeeeest; exit 1&quot; INT; start_other_background_services.sh; bash;'
  </code></pre>
  <p>If the above worked, I'd then try to find the entry point's PID and kill it</p>