Brent Baccala
Brent Baccala

Reputation: 1007

Can I build a docker container based on the host file system?

I want to use docker for its network isolation, but that's all.

More specifically, I want to run two programs and only allow network access a certain port on the one program if the connection is relayed through the second program. The one program is a VNC server and the second program is a Websocket relay with a custom authentication scheme.

So, I'm thinking about putting them both in a container and using docker port mappings to control their network access.

Can I setup docker so that I use the host's file system directly? I'd like to do things like access an .Xauthority file and create UNIX domain sockets (the VNC server does this). I know that I could mount the host filesystem in the container, but it'd be simpler to just use it directly as the container's filesystem. I think.

Is this possible? Easy?

Upvotes: 0

Views: 85

Answers (1)

BMitch
BMitch

Reputation: 264791

No, every container is based on an image that packages the filesystem layers. The filesystem namespace cannot be disabled in docker (unlike the network, pid, and other namespaces you can set to "host").

For your requirements, if you do not want to use host volume mounts, and do not want to package the application in an image, then you would be better off learning network namespaces in the Linux kernel which docker uses to implement container isolation. The ip netns command is a good place to start.

Upvotes: 1

Related Questions