Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How docker containers start services using systemct

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how the docker container uses systemct to start the service". In the actual case operation, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Use systemctl enable logstash to set the service to boot

2. Specify CMD ["/ usr/sbin/init"] in Dockerfile

Docker run-- privileged-d-it-v / data/test:/opt/logstash-e TZ=Asia/Tokyoreg.ptone.jp/base/logstash

Or

1. Use systemctl enable logstash to set the service to boot

2. Add script

ADD. / start.sh / usr/local/bin/start.shRUN chmod + x / usr/local/bin/start.shCMD ["/ usr/local/bin/start.sh"]

3 、

[root@dn-5-228 elk-docker] # cat start.shemaking raceme BASHEC / usr/sbin/initdocker run-- privileged-d-it-v / data/test:/opt/logstash-e TZ=Asia/Tokyo reg.ptone.jp/base/logstash

Using systemctl command to build centos7 container under Docker

1. Pull the centos7 image

Docker pull centos:latest

two。 Build a centos container

Docker run-tid-p 80:80-p 22:22-- privilaged-- name centos-2 centos:latest / usr/sbin/init

3. Enter into the container

Docker exec-it centos-2 bash

Check to see if systemctl is available

That's all for "how the docker container uses systemct to start the service". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report