简体   繁体   English

如何停止/启动在 docker 中运行的 logstash 服务

[英]How to stop/start logstash service running in docker

I'm trying to figure out how logstash works/run inside docker, and I'm stuck with simple thing like starting and stoping logstash.我试图弄清楚 logstash 如何在 docker 中工作/运行,并且我被困在简单的事情上,比如启动和停止 logstash。

I have started logstash docker container with simple run我已经通过简单的运行启动了 logstash docker 容器

docker run -it --name l2 logstash

and with result:结果:

 [Api Webserver] INFO  logstash.agent - Successfully started Logstash API endpoint {:port=>9600}

Next thing is runing /bin/bash with exec command, to get inside running container.接下来是使用 exec 命令运行 /bin/bash 以进入正在运行的容器。

docker exec -it l2 /bin/bash 
root@1b55d3a40d3f:/# 

Listing services status, shows that there is no logstash service running.列出服务状态,显示没有运行logstash 服务。 Where can I find logstash service and stop/start?我在哪里可以找到 logstash 服务并停止/启动?

root@1b55d3a40d3f:/# service --status-all 
 [ - ]  bootlogs
 [ - ]  bootmisc.sh
 [ - ]  checkfs.sh
 [ - ]  checkroot-bootclean.sh
 [ - ]  checkroot.sh
 [ - ]  dbus
 [ - ]  hostname.sh
 [ ? ]  hwclock.sh
 [ - ]  killprocs
 [ - ]  motd
 [ - ]  mountall-bootclean.sh
 [ - ]  mountall.sh
 [ - ]  mountdevsubfs.sh
 [ - ]  mountkernfs.sh
 [ - ]  mountnfs-bootclean.sh
 [ - ]  mountnfs.sh
 [ - ]  procps
 [ - ]  rc.local
 [ - ]  rmnologin
 [ - ]  sendsigs
 [ + ]  udev
 [ ? ]  udev-finish
 [ - ]  umountfs
 [ - ]  umountnfs.sh
 [ - ]  umountroot
 [ - ]  urandom
 [ - ]  x11-common

The logstash in the container is not run as a system service, the entrypoint in the image will start a process and will keep the container up until this process ends or fails.容器中的 logstash 不是作为系统服务运行的,镜像中的入口点将启动一个进程并保持容器运行,直到该进程结束或失败。

If you do a docker top l2 it will show the logstash process running (probaly alone) in the container.如果您执行 docker docker top l2 ,它将显示在容器中运行(可能单独)的 logstash 进程。

To stop the logstash, you need to stop the container with docker stop l2 , and later when you need to start it again you can run docker start l2 , it will work as long you set the containers name as 12 when you create or first run it.要停止logstash,您需要使用 docker docker stop l2停止容器,稍后当您需要再次启动它时,您可以运行docker start l2 ,只要您在创建或首次运行时将容器名称设置为docker start l2 ,它就会工作它。

Docker Start help: https://docs.docker.com/engine/reference/commandline/start/ Docker 启动帮助: https : //docs.docker.com/engine/reference/commandline/start/

Docker stop help: https://docs.docker.com/engine/reference/commandline/stop/ Docker 停止帮助: https : //docs.docker.com/engine/reference/commandline/stop/

Docker create: https://docs.docker.com/engine/reference/commandline/create/ Docker 创建: https : //docs.docker.com/engine/reference/commandline/create/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM