I have created a docker container which is up and running in the background. I tried to attach the container in my terminal using the container id. It enters the container but I can't do anything in it. So, I have to exit every time using ctrl+c.
Asked
Active
Viewed 46 times
0
-
Does this answer your question? [Why does "docker attach" hang?](https://stackoverflow.com/questions/35573698/why-does-docker-attach-hang) – Lawrence Cherone Nov 17 '20 at 19:04
1 Answers
0
If the comment by Lawrence Cherone did not help you consider the following options:
If you want to invoke a command in a already running container, use
docker exec
. You can exec into you container by it's name or id. This means you can run a command in a running container. See docs.docker.com: docker exec.Example:
The docker exec command runs the commandbash
in a running container.docker exec -it <container-id> bash
Note: This will really invoke a new command and do not attach to the currelty running command.
If you just want to get the putput of a container, you can use
docker logs
. Again you use your container name or id. See docs.docker.com: docker logsExample:
docker logs <container-id>

agentsmith
- 1,226
- 1
- 14
- 27