justincormack / nsenter1

simple nsenter to namespaces of pid 1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to use this image to expose volumes to other containers?

marcopeg opened this issue · comments

Hi Justin, I'm trying to tail the docker logs from a Node app.

Of course the problem seems to access the files itself, and your project looks a promising step toward a solution.

Is there a way to have your project expose /var/lib/docker as a volume that could be inherited by other containers?

Why can't you just do docker run -v /var/lib/docker:/var/libdocker ... to share this?

Hej, I'm not sure what do you mean. Here is a pseudo-coded docker-compose that express what I aim for:

services:

  nsenter1:
    image: justincormack/nsenter1
    ...

  myservice:
     image: foo
     volumes_from: nsenter
     volumes:
       - /var/run/docker.sock:/var/run/docker.sock

"myservice" should then be able to access host's docker info and logs even on MacOS.
Right now I've build a small utility that tries to tail the log files (on linux) and falls back on child process spawning a docker logs -f that give or takes works, but I read around is less efficient compared to tailing the files.

Marco

@justincormack I have the same question.

When I run docker run -it --rm --privileged --pid=host -v /var/lib/docker:/var/lib/docker justincormack/nsenter1 or any other host:guest combo, the folders don't link.

If the folders exist on both the host and the guest, the data isn't mirrored

Any ideas?

I'm wondering if anybody has managed to extract data from host image.

I've obviously tried to mount a volume, but as the previous commenter, it doesn't work.
docker run -it --rm --privileged --pid=host -v /var/lib/docker:/var/lib/docker justincormack/nsenter1

I then tried to just docker cp stuff out of there, but again that doesn't work.
Being relatively new to the more techie side of Docker, I don't understand why.

Interestingly, doing docker cp nsenter-container:/etc . copies only a handful of files, not the whole /etc folder.

Does anybody reading this know more?

Hi I made another repo that will dynamically add mounts to containers from any other namespace, including root and another container https://github.com/justincormack/addmount - its not the most polished UI, but it does work.