This is something I need to do routinely, but always forget to do.

When you run a docker image locally, how can you access the console? It is super easy to do if you have Docker Desktop and Docker Dashboard running. You can just click into the container and see the logs flow by on the console.

But, if you want to do do it via a command-line you need to use docker attach:

view plain print about
1docker attach my-running-docker-container

You need to use attach if you want to go into an existing session.

If you want to create a new session on a container, you can use exec

view plain print about
1docker exec my-running-docker-container

If I am gonna SSH into an existing container, then I usually want to use attach so I can see the console logs of whatever I have running.