Attaching to running containers

To retain control over a detached container, use docker attach command. The syntax for docker attach is quite simple:

$ docker attach [OPTIONS] <container ID or name>  

In our case this would be the ID we were given, when the container was started:

$ docker attach 5687bd611f84b53716424fd826984f551251bc95f3db49715fc7211a6bb23840  

At this time, if there is something that gets printed out, such as another log line from our running REST service, you will see it on the console. As you can see, the docker attach command can come in handy if you need to see what is written to the stdout stream in real time. It will basically reattach your console to the process running in the container. In other words, it will stream ...

Get Docker and Kubernetes for Java Developers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.