Docker:如何重新启动容器内部的进程? [英] Docker: how to restart process inside of container?

查看:1080
本文介绍了Docker:如何重新启动容器内部的进程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一组要在docker容器上运行的测试。
在测试过程中,我正在更改测试数据,并且需要重新启动JETTY。

I have a set of tests which I would like to run on docker container. In the middle of the tests I am changing me test data and I need to restart JETTY.

做到这一点的最佳方法是什么?

What is the best way to do that?

我可以想象一些选择:


  1. 使用SSH-但对于docker ssh不是最佳选择。

  1. With SSH - but for the docker ssh is not the best option.

docker上的Python代理可监听套接字-公开一个端口,连接并重新启动码头。

Python agent on docker to listen sockets - expose one more port, connect and restart jetty.

也许有更好的主意?

谢谢

推荐答案

听起来像您尝试重新启动的过程是Docker容器的主要过程(即,如果您有一个容器,则在Dockerfile中设置的容器,并且在运行 ps -ef'在容器内,您将看到进程的PID设置为1)。如果是这种情况,那么您将无法从容器内部重新启动它。您应该只重新启动容器本身:

Sounds like the process you're trying to restart is the primary process for the docker container (ie. the one you set in your Dockerfile if you have one, and when you run 'ps -ef' inside the container you would see the PID for your process set to 1). If this is the case, then you cannot restart it from inside the container. You should just restart the container itself:

docker restart <container_id>

这篇关于Docker:如何重新启动容器内部的进程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆