home / tils / til

Menu
  • GraphQL API

til: docker_attach-bash-to-running-container.md

Export data

til

This row where path = "docker_attach-bash-to-running-container.md"

TSV
Tab-separated values, for pasting into Excel or Google Sheets
CSV
Comma-separated values, for spreadsheets and other tools
  • JSON
    The row inside an object, with extra details
    View Download

path
docker_attach-bash-to-running-container.md
topic
docker
title
Attaching a bash shell to a running Docker container
url
https://github.com/simonw/til/blob/main/docker/attach-bash-to-running-container.md
body
Use `docker ps` to find the container ID: $ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 81b2ad3194cb alexdebrie/livegrep-base:1 "/livegrep-github-re…" 2 minutes ago Up 2 minutes compassionate_yalow Run `docker exec -it ID bash` to start a bash session in that container: $ docker exec -it 81b2ad3194cb bash I made the mistake of using `docker attach 81b2ad3194cb` first, which attaches you to the command running as CMD in that conatiner, and means that if you hit `Ctrl+C` you exit that command and terminate the container!
html
<p>Use <code>docker ps</code> to find the container ID:</p> <pre><code>$ docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 81b2ad3194cb alexdebrie/livegrep-base:1 "/livegrep-github-re…" 2 minutes ago Up 2 minutes compassionate_yalow </code></pre> <p>Run <code>docker exec -it ID bash</code> to start a bash session in that container:</p> <pre><code>$ docker exec -it 81b2ad3194cb bash </code></pre> <p>I made the mistake of using <code>docker attach 81b2ad3194cb</code> first, which attaches you to the command running as CMD in that conatiner, and means that if you hit <code>Ctrl+C</code> you exit that command and terminate the container!</p>
shot
<Binary: 61,636 bytes>
created
2020-08-10T08:41:01-07:00
created_utc
2020-08-10T15:41:01+00:00
updated
2020-08-10T08:41:01-07:00
updated_utc
2020-08-10T15:41:01+00:00
shot_hash
2bd34a112abf7858d6a88c4da46c3bda
slug
attach-bash-to-running-container
Powered by Datasette · How this site works · Code of conduct