能在Dockerfile中用systemd启动服务吗
答案:1 悬赏:30 手机版
解决时间 2021-02-27 20:45
- 提问者网友:做自己de王妃
- 2021-02-27 13:17
能在Dockerfile中用systemd启动服务吗
最佳答案
- 五星知识达人网友:拜訪者
- 2021-02-27 14:30
docker run的时候给予特权就可以使用了。
[root@ip-10-10-17-4 ~]# docker run --restart always -d --name='23' --privileged 2k0ri/centos7-systemd:latest /sbin/init
c65fcd9789405cc3c76320d3920ce0ff266869abf06718ef0101f0a11564f3b7
[root@ip-10-10-17-4 ~]# docker exec -it 23 /bin/bash
[root@c65fcd978940 /]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[root@c65fcd978940 /]# systemctl status sshd
sshd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@c65fcd978940 /]#
[root@ip-10-10-17-4 ~]# docker run --restart always -d --name='23' --privileged 2k0ri/centos7-systemd:latest /sbin/init
c65fcd9789405cc3c76320d3920ce0ff266869abf06718ef0101f0a11564f3b7
[root@ip-10-10-17-4 ~]# docker exec -it 23 /bin/bash
[root@c65fcd978940 /]# cat /etc/redhat-release
CentOS Linux release 7.1.1503 (Core)
[root@c65fcd978940 /]# systemctl status sshd
sshd.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
[root@c65fcd978940 /]#
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯