在 Docker 容器中重启 nginx

Sno*_*ash 5 nginx docker

我的 Docker 容器似乎没有service命令。我将如何重新启动nginx

例如

# uname -r
3.13.0-119-generic
bash-4.3# uname -a
Linux <container id> 3.13.0-119-generic #166-Ubuntu SMP Wed May 3 12:18:55 UTC 2017 x86_64 Linux
bash-4.3# service nginx restart
bash: service: command not found
Run Code Online (Sandbox Code Playgroud)

ser*_*ech 4

这取决于您的容器运行的是 systemd、sysV 还是 upstart。

此时有效的选择是

/etc/init.d/nginx restart
Run Code Online (Sandbox Code Playgroud)

systemctl restart nginx
Run Code Online (Sandbox Code Playgroud)