Today I learned docker container can act as if it was an application running on the host system with little effort
# Build docker image $ docker build -t seamless-docker . # Run a process in an isolated container $ docker run --net host --volume `pwd`/shared:/shared seamless-docker
Let's break it down:
--net host exposes host network to the container helping the program running in the container act as if it was running in the host system.
--volume `pwd`/shared:/shared creates a shared volume between the host system and the container. It supports writes unless we add
:ro at the end. Any time modification is made in the host system or the container, the other will get the update.
By default Docker Desktop on MacOS does not allow creating a shared volume unless the directory is whitelisted. Some directories are whitelisted by default. File Sharing preferences can be changed in
Docker -> Preferences -> File Sharing