简体   繁体   English

Podman (docker) 容器

[英]Podman (docker) container

Does someone know how to start and stop services inside the container?有人知道如何在容器内启动和停止服务吗?

Eg wish to stop sshd service INSIDE the Ubuntu container, but not in the whole host (RHEL).例如,希望在 Ubuntu 容器内停止 sshd 服务,而不是在整个主机 (RHEL) 中。

您需要使用docker exec -it <container_name> /bin/bash在容器中获取一个 root shell,然后您可以运行您想要的命令

  1. Log in to the container using the below command使用以下命令登录容器

    docker exec -it <container_id> /bin/bash

  2. Using any of the below commands can stop the ssh service使用以下任何命令都可以停止 ssh 服务

    $ sudo /etc/init.d/ssh stop or $ sudo service ssh stop or $ sudo systemctl stop ssh $ sudo /etc/init.d/ssh stop$ sudo service ssh stop$ sudo systemctl stop ssh

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

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