0

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.

enter image description here

Lawrence Cherone
  • 46,049
  • 7
  • 62
  • 106
  • 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 Answers1

0

If the comment by Lawrence Cherone did not help you consider the following options:

  1. 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 command bash 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.

  2. 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 logs

    Example:

    docker logs <container-id>
    
agentsmith
  • 1,226
  • 1
  • 14
  • 27