Skip to content
This repository has been archived by the owner on Feb 7, 2022. It is now read-only.

Allow to pass flags to docker run #179

Open
sungwoncho opened this issue Feb 5, 2020 · 0 comments
Open

Allow to pass flags to docker run #179

sungwoncho opened this issue Feb 5, 2020 · 0 comments

Comments

@sungwoncho
Copy link

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/[email protected]: 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

xgo/xgo.go

Lines 284 to 301 in c5ccff8

args := []string{
"run", "--rm",
"-v", folder + ":/build",
"-v", depsCache + ":/deps-cache:ro",
"-e", "REPO_REMOTE=" + config.Remote,
"-e", "REPO_BRANCH=" + config.Branch,
"-e", "PACK=" + config.Package,
"-e", "DEPS=" + config.Dependencies,
"-e", "ARGS=" + config.Arguments,
"-e", "OUT=" + config.Prefix,
"-e", fmt.Sprintf("FLAG_V=%v", flags.Verbose),
"-e", fmt.Sprintf("FLAG_X=%v", flags.Steps),
"-e", fmt.Sprintf("FLAG_RACE=%v", flags.Race),
"-e", fmt.Sprintf("FLAG_TAGS=%s", flags.Tags),
"-e", fmt.Sprintf("FLAG_LDFLAGS=%s", flags.LdFlags),
"-e", fmt.Sprintf("FLAG_BUILDMODE=%s", flags.Mode),
"-e", "TARGETS=" + strings.Replace(strings.Join(config.Targets, " "), "*", ".", -1),
}

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant