O'Reilly logo

Docker and Kubernetes for Java Developers by Jaroslaw Krochmalski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required