karalabe / xgo

Go CGO cross compiler
MIT License
2.14k stars 280 forks source link

Allow to pass flags to `docker run` #179

Open sungwoncho opened 4 years ago

sungwoncho commented 4 years ago

It would be useful to be able to pass a flag to docker run.

A use case is passing flags such as --net=host to be able to access the Internet from inside a docker container. I had a case in which xgo was failing because it could not fetch go modules for a project due to some DNS-related issue preventing the Internet from being available inside a container. The error was something like:

go: github.com/Azure/azure-pipeline-go@v0.2.2: Get https://proxy.golang.org/github.com/%21azure/azure-pipeline-go/@v/v0.2.2.mod: dial tcp: lookup proxy.golang.org on 8.8.4.4:53: read udp 172.17.0.2:452 598->8.8.4.4:53: i/o timeout

I have managed to bypass it by forking the project, and adding "--net", "host" to https://github.com/karalabe/xgo/blob/c5ccff8648a77686d274c1984e1cd6319736f5cb/xgo.go#L284-L301

What do you think about adding a flag in xgo such as -dockerflag? I am happy to make a PR.