Command to detach console *from within the container*

We know how to detach a console from docker host

To detach the tty without exiting the shell, use the escape sequence Ctrl-p + Ctrl-q. The container will continue to exist in a stopped state once exited.

Can we do that with a command from within the container console (to be eventually leveraged by a script inside the container)?

Why not just use docker exec Instead of docker attach in your scritps?

Sorry for the late reply, just for the record.

I needed this because I have a central script that open console windows to multiple containers, and each time it needs to get back to the main script to perform other tasks.

I still don’t understand, docker exec will run a command in your container and exit back into your main script.

Not if you run it with interactive mode “-ti” and pass “/bin/bash” to the container.
I agree that it is a peculiar case, but I needed that for the earlier intergration testing with GNS3:

But this is not needed anymore, because now Docker is officially integrated into GNS3 “natively” and provide console access to the containes on-demand:
Here is an example:

I hope I 've made myself clear about the context of the post.

I know this is a bit old thread but… I just tested “Ctrl P + Q” just like Linux containers, and it worked.