Nir L
Nir L

Reputation: 1

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.

Upvotes: 0

Views: 1179

Answers (1)

Jan Garaj
Jan Garaj

Reputation: 28656

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

Upvotes: 1

Related Questions