是否可以在停止Docker容器时运行命令?

时间:2016-08-21 19:18:52

标签: docker npm docker-compose

我使用docker-compose为JS应用程序组织容器 源容器运行command: npm start,非常标准,以启动实时应用程序。但是,当我要求它停止时,超时。

我想知道是否可以docker-compose stop在容器内运行命令 - 这可以正确终止应用程序。

1 个答案:

答案 0 :(得分:2)

private void checkDataNotExistInList(String text) { MyListFragment myListFragment = (MyListFragment)mActivity.getFragmentManager() .findFragmentById(R.id.frgMyList); assertNotNull(myListFragment); ListAdapter listAdapter = (ListAdapter) myListFragment.getListAdapter(); for (int i = 0; i < listAdapter.getCount(); i++) { assertThat("Item is in the list", text, is(not(listAdapter.getItem(i).getName()))); } } 只需向您的容器发送docker-compose stop,如果在10secs(可配置)SIGTERM之后没有停止。因此,如果您想自定义此行为,您应该处理SIGKILL内的信号(如果有的话)。

相关问题