Stack: --docker-run-args doesn't remove default args

Created on 15 Dec 2019  Â·  4Comments  Â·  Source: commercialhaskell/stack

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...

Most helpful comment

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?

All 4 comments

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?

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

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.

Sorry for the delay. PR is submitted now (:

Was this page helpful?
0 / 5 - 0 ratings