Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--docker-run-args doesn't remove default args #5121

Closed
stevemao opened this issue Dec 15, 2019 · 4 comments
Closed

--docker-run-args doesn't remove default args #5121

stevemao opened this issue Dec 15, 2019 · 4 comments

Comments

@stevemao
Copy link
Contributor

stack --docker-run-args='--net=bridge --publish=3000:3000' --docker run

Should overwrite the default docker args, but it just simply appends:

Error response from daemon: Container cannot be connected to network endpoints: bridge, host
Received ExitFailure 1 when running
Raw command: /usr/local/bin/docker create --net=host -e STACK_IN_CONTAINER=1 -e STACK_ROOT=/Users/stevemao/.stack -e STACK_PLATFORM_VARIANT=dkda49f7ca9b244180d3cfb1987cbc9743 -e HOME=/Users/stevemao/workdir/engine/.stack-work/docker/_home -e PATH=/opt/host/bin:/Users/stevemao/workdir/engine/.stack-work/docker/_home/.local/bin:/root/.local/bin:/usr/local/cuda-10.0/bin:/home/stackage/.stack/programs/x86_64-linux/ghc-8.6.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -e PWD=/Users/stevemao/workdir/engine -v /Users/stevemao:/Users/stevemao -v /Users/stevemao/.stack:/Users/stevemao/.stack -v /Users/stevemao/workdir/engine:/Users/stevemao/workdir/engine -v /Users/stevemao/workdir/engine/.stack-work/docker/_home:/Users/stevemao/workdir/engine/.stack-work/docker/_home -w /Users/stevemao/workdir/engine -e USER=stevemao -e SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners -v /private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners:/private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners -v /Users/stevemao/.stack/programs/x86_64-linux/stack-2.1.3/stack:/opt/host/bin/stack -t -i --net=bridge --publish=3000:3000 fpco/stack-build:lts-14.17 /opt/host/bin/stack --internal-re-exec-version=2.1.3 --internal-docker-entrypoint "DockerEntrypoint {deUser = Just (DockerUser {duUid = 501, duGid = 20, duGroups = [20,12,61,79,80,81,98,701,33,100,204,250,395,398,399], duUmask = 18})}" "--docker-run-args=--net=bridge --publish=3000:3000" --docker run

Expected:

Raw command: /usr/local/bin/docker create -e STACK_IN_CONTAINER=1 -e STACK_ROOT=/Users/stevemao/.stack -e STACK_PLATFORM_VARIANT=dkda49f7ca9b244180d3cfb1987cbc9743 -e HOME=/Users/stevemao/workdir/engine/.stack-work/docker/_home -e PATH=/opt/host/bin:/Users/stevemao/workdir/engine/.stack-work/docker/_home/.local/bin:/root/.local/bin:/usr/local/cuda-10.0/bin:/home/stackage/.stack/programs/x86_64-linux/ghc-8.6.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin -e PWD=/Users/stevemao/workdir/engine -v /Users/stevemao:/Users/stevemao -v /Users/stevemao/.stack:/Users/stevemao/.stack -v /Users/stevemao/workdir/engine:/Users/stevemao/workdir/engine -v /Users/stevemao/workdir/engine/.stack-work/docker/_home:/Users/stevemao/workdir/engine/.stack-work/docker/_home -w /Users/stevemao/workdir/engine -e USER=stevemao -e SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners -v /private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners:/private/tmp/com.apple.launchd.JaXyY2U2GA/Listeners -v /Users/stevemao/.stack/programs/x86_64-linux/stack-2.1.3/stack:/opt/host/bin/stack -t -i --net=bridge --publish=3000:3000 fpco/stack-build:lts-14.17 /opt/host/bin/stack --internal-re-exec-version=2.1.3 --internal-docker-entrypoint "DockerEntrypoint {deUser = Just (DockerUser {duUid = 501, duGid = 20, duGroups = [20,12,61,79,80,81,98,701,33,100,204,250,395,398,399], duUmask = 18})}" "--docker-run-args=--net=bridge --publish=3000:3000" --docker run

Because --net=host doesn't work on Mac (https://forums.docker.com/t/should-docker-run-net-host-work/14215) so I cannot connect to the server...

@mrArkwright
Copy link
Contributor

This could be solved by introducing a --docker-network option which overrides the --net=host option passed to docker rather than adding an additional (conflicting) --net= via --docker-run-args. On macOS this could then be set to bridge in the stack.yaml or via the command line to enable docker port publishing to the host.

If --docker-network is omitted it should default to passing --net=host to docker to preserve compatibility with existing installations of stack.

I already tested this on my local Mac. Should I submit a pull request?

Also I ran into the problem that I had to work on the v2.1.3 tag rather than the master branch because otherwise stack wouldn't find a Docker-compatible stack executable for the current version. This seems to be natural since the version under development can't be published yet. Still, is there any way around this for developing?

@lucch
Copy link

lucch commented Apr 21, 2020

Same problem here. Can't wait to see this merged/fixed. 🙂

@lucch
Copy link

lucch commented Apr 21, 2020

I think it relates to #2455, but the solution presented there (overriding --net=host with --net=bridge through docker-run-args) is not working anymore as pointed out by the OP. Meanwhile, would you share the link to your solution @mrArkwright? Couldn't find it in your fork.

@mrArkwright
Copy link
Contributor

Sorry for the delay. PR is submitted now (:

borsboom added a commit that referenced this issue Jun 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants