0

My app runs as a privileged docker container on linux hosts. Inside the app I want to execute a command on the host system and get the output. What is the best way to do it. Can nsenter be helpful?

  • The best way to do this is to run your process outside Docker. You might be able to do complicated things with namespaces to escape a privileged container, but then you're not really getting any advantage from the Docker setup. – David Maze Dec 12 '19 at 01:04
  • @DavidMaze Could you elaborate how to take advantage of docker environment – alok aggarwal Dec 13 '19 at 00:31
  • @ShayK I am executing an rpm query. I want to execute this query on the host from my app which is running in a privileged container. – alok aggarwal Dec 13 '19 at 00:33
  • Docker is an isolation environment that's especially good at packaging self-contained network servers. Since it's an isolation environment, it's especially bad at tasks that involve administering the host the container runs on, or at managing the host's filesystem. If you want to manage things like the host's installed packages you need to run this task completely outside of Docker. – David Maze Dec 13 '19 at 00:33
  • https://stackoverflow.com/a/49873529/2879188 – ShayK Dec 13 '19 at 04:59

1 Answers1

0

Yes, this is doable!

Check out this blog

Brad Pitt
  • 398
  • 3
  • 11