docker中使用systemctl启动服务

解决
Failed to get D-Bus connection: Operation not permitted
https://serverfault.com/questions/824975/failed-to-get-d-bus-connection-operation-not-permitted
 
1、使用systemctl enable logstash 将服务设置成开机启动
2、Dockerfile中指定     CMD ["/usr/sbin/init”] 
docker run --privileged -d -it -v /data/test:/opt/logstash -e TZ=Asia/Tokyo reg.ptone.jp/base/logstash 
或者
1、使用systemctl enable logstash 将服务设置成开机启动
2、添加脚本
ADD ./start.sh /usr/local/bin/start.sh
RUN chmod +x /usr/local/bin/start.sh
CMD ["/usr/local/bin/start.sh"]
3、
[root@dn-5-228 elk-docker]# cat start.sh
#!/bin/bash
exec /usr/sbin/init
 
docker run --privileged -d -it -v /data/test:/opt/logstash -e TZ=Asia/Tokyo reg.ptone.jp/base/logstash

 

转载于:https://www.cnblogs.com/cptao/p/10913382.html

你可能感兴趣的:(docker中使用systemctl启动服务)