matthieudelaro / nut

Nut: the development environment, containerized.
GNU General Public License v3.0
258 stars 16 forks source link

`--net` option not respected #23

Open markjlorenz opened 8 years ago

markjlorenz commented 8 years ago

I tried this with the OSX binary from releases, and also after following the instructions to build from the latest source...

Using the following nut.yml

syntax_version: "6"
project_name: chrome
macros:
  run:
    usage: run chrome in the container
    docker_image: jess/chrome
    enable_gui: true
    security_opts:
      - seccomp=unconfined
    uts: shouldcrash
    net: shouldcrash
uts: shouldcrash
net: shouldcrash

and running ./nut run

with this directory structure:

.
├── nut
└── nut.yml

The container starts up chrome, I would have expected it to crash, since shouldcrash isn't a docker network available on my system:

nut → docker network ls
NETWORK ID          NAME                    DRIVER              SCOPE
3c7e04afb272        bridge                  bridge              local
e2ea9b453b2f        earningscalls_default   bridge              local
a196955a3287        host                    host                local
94b4c00ffe64        none                    null                local
94b4c00ffe64        none                    null                local

I got here by trying to connect to a network that I do have available (earningscalls_default), but thought a non-existent network would be more reproducible for you.


I think this is unrelated, but worth nothing...

I dug around in the code a little bit, and it looks like the flags for --uts and --net are flipped:

        if value := dockerHostConfig.NetworkMode; value != "" {
            dockercall = append(dockercall, "--uts=\"" + value + "\"")  <--- Should be net?
        }
        if value := dockerHostConfig.UTSMode; value != "" {
            dockercall = append(dockercall, "--net=\"" + value + "\"")   <--- Should be uts?
        }
matthieudelaro commented 8 years ago

Hello @dapplebeforedawn,

Sorry for late answer, and thanks for reporting this issue, after digging through the source code to find relevant info. 1) Net and switch have been swapped, indeed. 2) As for the "non-warning-nor-crash" behavior, I think that Nut should behave like Docker CLI. What happens if you run something like docker run --net=shouldcrash? In case it doesn't fire any error, then I guess Nut shouldn't either.

Unfortunately, I won't be able to work on this (please see #24 ). But if you submit a PR (without any conflict) which solves the issue, I'll review it, so that the whole community can benefit from it.

Thanks by advance,

markjlorenz commented 8 years ago

Thanks, I appreciate that!

If given an invalid network name, docker CLI returns an error. I agree, nut should do the same.

On Thursday, October 13, 2016, matthieudelaro notifications@github.com wrote:

Hello @dapplebeforedawn https://github.com/dapplebeforedawn,

Sorry for late answer, and thanks for reporting this issue, after digging through the source code to find relevant info. 1) Net and switch have been swapped, indeed. 2) As for the "non-warning-nor-crash" behavior, I think that Nut should behave like Docker CLI. What happens if you run something like docker run --net=shouldcrash? In case it doesn't fire any error, then I guess Nut shouldn't either.

Unfortunately, I won't be able to work on this (please see #24 https://github.com/matthieudelaro/nut/issues/24 ). But if you submit a PR (without any conflict) which solves the issue, I'll review it, so that the whole community can benefit from it.

Thanks by advance,

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/matthieudelaro/nut/issues/23#issuecomment-253648154, or mute the thread https://github.com/notifications/unsubscribe-auth/AALzjUITdnPnvA0BbHTWpdFeEbcWVC_Qks5qzqaEgaJpZM4KJVJP .

Mark J. Lorenz Dapple Before Dawn 1756 Darrow Dr. Powell, Ohio 43065 (p) 614-537-6728