如何确定docker exec中的命令何时完成
I'm currently using the Docker Rest API to run an exec command on a container to start building a maven project. I was wondering if there was any way provided by Docker to determine when the cmds you attach to the exec cmd complete or if I need to start getting creative
我目前正在使用Docker Rest API在容器上运行exec命令以开始构建Maven项目。 我想知道Docker是否提供任何方法来确定您附加到exec cmd的cmd是何时完成,还是我需要开始变得有创意 p> div>
From the exec api spec if you do not set detach to true, the web socket should close once the command finishes. If you do detach from the the exec, then you can use the exec inspect api and poll for Running to go to false.
If you're using the exec api to run an interactive shell and you run your commands as input to the shell without closing stdin, then that shell will hang just as if you ran it outside of docker. You can close stdin to the shell or you'll need to "get creative" if that's not an option.