简体   繁体   中英

How to install / run service or command on host machine from a docker container

I'm trying to find a good way to run a command on a linux host machine from within a privileged docker container and I want the command to execute within the context of the host.

For example I want the ability to execute some auditing tool that scans the host. The tool is available inside the container and I want it to execute on the host.

Also, I'd like the ability to install a package on the host (specifically Auditd) from the container.

The container can be run with any privileges required for this.

Any help would be appreciated.

Installation:

  • mount host FS into container ( -v /:/rootfs/ ) and then run cp in the container, which will copy all required files to that mount /rootfs. Be carefull with dynamic linked binaries - they must be prepared for the host OS, not for container env (they may have different lib, glibc versions).

Management of host services:

  • majority of Linuxes use systemd, so just mount required sockets into container ( -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd ) and then systemd utilities ( systemctl ) from the container will be able to manage host systemd services

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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