stepchowfun / toast

Containerize your development and continuous integration environments. 🥂
Other
1.57k stars 39 forks source link

Adding an optional `net` or `network` corresponding to the `--network` flag in docker cli #452

Closed yihuaf closed 1 year ago

yihuaf commented 1 year ago

Description I would like to add an option to specify the network namespace akin to what docker cli --network does. In some cases, I would like to drop the container into host network namespace in order to access other resources running on the dev machine. For example, I run a testing consul through the docker compose stack with some testing data. The consul has port mapped the the host network namespace correctly, 8500 for example. In toast, I would like to access that port, but I have no way to specify that.

Alternatives considered I don't think there is a good alternatives for this particular usecase within toast. I can however to package a runtime container myself using toast only as the build step. I can use normal docker build step to copy the binary from toast build steps and execute docker command myself wrapped by a command runner.

Additional context The change looks to amend the create_container and container_args call to add the --network flag when executing docker cli. We can either allow any network to be passed in from toast and let docker cli return errors in the case that it is incorrect, or specify only dropping to host network as a boolean flag.

If you are open to this feature, I am happy to submit a PR for this.

yihuaf commented 1 year ago

Actually extra_docker_arguments works great with --net=host.