Skip to content

🐞Cannot build in private network #2228

Closed

Description

@rinrinne

What is the issue?

I cannot build example todoapp. Maybe because I'm in private network (not reachable to any public DNS)

Log output

~/github.com/dagger/pkg/universe.dagger.io/examples/todoapp$ dagger do build
11:33PM INF upgrading buildkit    have host network=false version=v0.10.1
WARN[0008] commandConn.CloseWrite: commandconn: failed to wait: signal: terminated
WARN[0008] commandConn.CloseRead: commandconn: failed to wait: signal: terminated 
11:33PM INF upgrading buildkit    have host network=false version=v0.10.1
[✔] actions.build.run.script
[✗] actions.deps
#8 0.325 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/main/x86_64/APKINDEX.tar.gz
#8 5.331 fetch https://dl-cdn.alpinelinux.org/alpine/v3.15/community/x86_64/APKINDEX.tar.gz
#8 5.331 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/main: temporary error (try again later)
#8 10.34 WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.15/community: temporary error (try again later)
#8 10.34 ERROR: unable to select packages:
#8 10.34   bash (no such package):
#8 10.34     required by: world[bash]
[✔] actions.test.script
[✔] client.filesystem."./".read
11:33PM FTL failed to execute plan: task failed: actions.deps._dag."0"._dag."1"._exec: process "apk -U --no-cache add bash" did not complete successfully: exit code: 1
~/github.com/dagger/pkg/universe.dagger.io/examples/todoapp$

Steps to reproduce

  1. Install dagger
$ git clone https://github.com/dagger
$ cd dagger/pkg/universe.dagger.io/examples/todoapp
$ dagger do build

Dagger version

dagger 0.2.6 (e2c2213) linux/amd64

OS version

Ubuntu 18.04

Activity

  1. rinrinne commented on Apr 19, 2022

    @rinrinne
    Author

    If run buildkit container with the following command then run dagger, build is successful

    $ docker run -d --rm -v `pwd`/buildkitd.toml:/etc/buildkit/buildkitd.toml:ro --name dagger-buildkitd --privileged --net=host moby/buildkit:v0.10.1
    

    buildkitd.toml

    [dns]
      nameservers=["xx.xx.xx.xx"]
    

    xx.xx.xx.xx is our private DNS

  2. marcosnils commented on Apr 19, 2022

    @marcosnils
    Contributor

    This is interesting, IIRC any container that you run in your machine should use your main system DNS configuration by default unless specifically overridden. Which setup are you currently using? Mac, Windows, Linux?

    If you run a stand alone container, does it have DNS resolution out of the box?

  3. rinrinne commented on Apr 19, 2022

    @rinrinne
    Author

    I'm using Ubuntu desktop 18.04, already described in issue report.

    Host's /etc/resolv.conf

    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    # 127.0.0.53 is the systemd-resolved stub resolver.
    # run "systemd-resolve --status" to see details about the actual nameservers.
    
    nameserver 127.0.0.53
    
  4. marcosnils commented on Apr 19, 2022

    @marcosnils
    Contributor

    I'm using Ubuntu desktop 18.04, already described in issue report.

    my bad, I missed this.

    Host's /etc/resolv.conf

    Yes, that's using the default systemd-resolve service.

    If you create a stand alone container, does resolution work?

    docker run --rm alpine ping google.com

  5. rinrinne commented on Apr 19, 2022

    @rinrinne
    Author

    If you create a stand alone container, does resolution work?

    yes, works.

    I ran buildctl in dagger started buildkit container with the following Dockerfile

    FROM alpine:3.15.0
    
    RUN cat /etc/resolv.conf
    
    # buildctl build --no-cache --progress plain --frontend dockerfile.v0 --local dockerfile=.
    

    Result

    #5 [2/2] RUN cat /etc/resolv.conf
    #5 0.510 
    #5 0.510 nameserver 8.8.8.8
    #5 0.510 nameserver 8.8.4.4
    #5 0.510 nameserver 2001:4860:4860::8888
    #5 0.510 nameserver 2001:4860:4860::8844
    #5 DONE 1.0s
    
  6. marcosnils commented on Apr 19, 2022

    @marcosnils
    Contributor

    I ran buildctl in dagger started buildkit container with the following Dockerfile

    Oh! I see what's happening here. Since we're running dind like containers containerd and libnetwork is fallbacking to 8.8.8.8. I guess potentially we'd need a dagger.Conf definition to start adding all these non-dagger specific configs and pass them to underlying systems like buildkit.

    @helderco @aluzzardi @shykes haven't found an issue / feature for this. I recall seeing some issues related but AFIAK we haven't taken any decision on how to tackle this.

    Related:
    #1369
    #2227

  7. rinrinne commented on Apr 20, 2022

    @rinrinne
    Author

    Seems /etc/resolve.conf in host is delivered to buildkit container if "docker run" with --net=host, If default (--net=bridge), /run/systemd/resolve/resolv.conf in host is delivered as /etc/resolv.conf.

  8. added
    kind/bug
    on May 17, 2022
  9. juaruipav commented on Jun 30, 2022

    @juaruipav

    Any progress on this? I'm sadly in the same situation.

    Thanks!
    JJ

  10. marcosnils commented on Dec 2, 2023

    @marcosnils
    Contributor

    Closing this since it's a very outdated issue and haven't seen anyone reporting this anymore

  11. kema-dev commented on Jan 31, 2024

    @kema-dev

    Hello, I'm experiencing issues that might be related to this. I am using a wireguard VPN.
    Following get started procedure for go, I get networking errors as follows

    Details
    dagger run go run ci/main.go            
    ┣─╮ 
    │ ▽ init
    │ █ [1.13s] connect
    │ ┣ [0.23s] starting engine
    │ ┣ [0.22s] starting session
    │ ┃ OK!                                                                                                                                                                                    
    │ ┻ 
    █ [10.65s] ERROR go run ci/main.go
    ┃ panic: input: resolve: container: from: failed to authorize: failed to fetch anonymous token: Get "https://auth.docker.io/token?scope=repository%3Alibrary%2Fgolang%3Apull&service=regist
    ┃ ry.docker.io": dial tcp: lookup auth.docker.io on <REDACTED VPN IP>:53: read udp <REDACTED VPN IP>:51747-><REDACTED VPN IP>:53: i/o timeout                                                                      
    ┃ input: resolve: container: from: failed to authorize: failed to fetch anonymous token: Get "https://auth.docker.io/token?scope=repository%3Alibrary%2Fgolang%3Apull&service=registry.dock
    ┃ er.io": dial tcp: lookup auth.docker.io on <REDACTED VPN IP>:53: read udp <REDACTED VPN IP>:51747-><REDACTED VPN IP>:53: i/o timeout                                                                             
    ┃                                                                                                                                                                                          
    ┃                                                                                                                                                                                          
    ┃ goroutine 1 [running]:                                                                                                                                                                   
    ┃ main.main()                                                                                                                                                                              
    ┃         /tmp/hello-dagger/ci/main.go:28 +0x3d2                                                                                                                                           
    ┃ exit status 2                                                                                                                                                                            
    █ [10.02s] ERROR from
    ┣─╮ 
    │ ▼ from
    │ ┣─╮ 
    │ │ ▽ from golang:1.19
    │ │ █ [10.01s] ERROR resolve image config for docker.io/library/golang:1.19
    ┻ ┻ ┻ 
    • Engine: 50b6ae46f94b (version v0.9.7)
    ⧗ 11.80s ✔ 7 ✘ 3
    exit status 1
    

    Setting custom DNS to Cloudflare's 1.1.1.1 fixes the issue. Using the VPN without custom DNS, I am able to docker pull the image and to fetch the docker auth anonymous token without any issue. Running using nodejs SDK give about same output as GraphQL errors reporting timeouts on docker registry endpoints.

    I installed dagger on Fedora 39 using brew, which gave me the same binary as the installation script.

  12. marcosnils commented on Feb 2, 2024

    @marcosnils
    Contributor

    hey there! if you run the following commands:

    docker run --rm alpine cat /etc/resolv.conf

    // engine container needs to be running
    docker exec $(docker ps --filter name=dagger-engine- -q) cat /etc/dnsmasq-resolv.conf. Do you see a valid

    do you see the same nameserver ip?

  13. kema-dev commented on Feb 3, 2024

    @kema-dev

    Looks like nameservers are the same. Sometimes when I delete the dagger-engine container and re-create it, the 2 selected NS are not the same in each container, but I still overall get 3 same servers : <NS from VPN> <router> and 1.1.1.1.

    ➜ docker run --rm alpine cat /etc/resolv.conf | tail && docker exec $(docker ps --filter name=dagger-engine- -q) cat /etc/dnsmasq-resolv.conf | tail
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 1.1.1.1
    nameserver <router>
    # Too many DNS servers configured, the following entries may be ignored.
    nameserver <NS from VPN>
    nameserver 1.1.1.1
    nameserver <router>
    search .
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 1.1.1.1
    nameserver <router>
    # Too many DNS servers configured, the following entries may be ignored.
    nameserver <NS from VPN>
    nameserver 1.1.1.1
    nameserver <router>
    search .

    Running nslookup in interactive shell inside the dagger-engine container gives same result, only works when no VPN / VPN but 1.1.1.1 NS set. However, once cached, I can wget -qO- <server name / IP> successfully most of the time. If i do not run wget for about 1 minute, I get 2/3 tries returning bad address, then it works. 😕

  14. marcosnils commented on Feb 4, 2024

    @marcosnils
    Contributor

    Running nslookup in interactive shell inside the dagger-engine container gives same result, only works when no VPN / VPN but 1.1.1.1 NS set. However, once cached, I can wget -qO- <server name / IP> successfully most of the time. If i do not run wget for about 1 minute, I get 2/3 tries returning bad address, then it works. 😕

    I think I know what's happening here. Basically each time you disconnect from the VPN you need to "remove" the docker engine since otherwise it'll keep the wrong DNS servers from old VPN sessions. Try doing the following:

    1. Remove the dagger-engine container
    2. Connect to VPN
    3. Test if connectivity works
    4. Disconnect from VPN

    Start again in #1 and repeat.

    That should work.

  15. kema-dev commented on Feb 4, 2024

    @kema-dev

    I ran your steps, but it unfortunately didn't work.

    However, it looks like I misunderstood what's happening. My wget command behavior is “consistent” (in the sense it happens even if I permanently use my VPN). Same behavior for nslookup calls, fails at first, then hits, then fails again if I do not make calls for about 1 minute.

    Local machine nslookup using <NS FROM VPN> works like a charm, as well as using the custom one if defined in VPN config (1.1.1.1), but any other NS is blocked. The same goes inside dagger-engine container, forcing the right NS I get no issue. Container's /etc/resolve.conf is classical, giving its own IP as resolver. I saw no specific configuration of dnsmasq inside dagger's container, as you can see its dnsmasq resolver looks the same as the bare-alpine's resolve.conf.

    I wonder if something like a round-robin selection of a NS could happen ? In a bare-alpine, nslookup calls are trying using <ROUTER IP> and 1.1.1.1 with failures, then resolves successfully. Might dagger select a specific NS and try only this one for a set amount of time or w/e ?

  16. marcosnils commented on Feb 5, 2024

    @marcosnils
    Contributor

    Would you run this command again please (#2228 (comment)) with the VPN conneted but separate the outputs clearly? from your output I cant easily tell what's coming from where.

  17. kema-dev commented on Feb 5, 2024

    @kema-dev

    Sorry for this, here are the outputs:

    Bare alpine:

    # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
    # Do not edit.
    #
    # This file might be symlinked as /etc/resolv.conf. If you're looking at
    # /etc/resolv.conf and seeing this text, you have followed the symlink.
    #
    # This is a dynamic resolv.conf file for connecting local clients directly to
    # all known uplink DNS servers. This file lists all configured search domains.
    #
    # Third party programs should typically not access this file directly, but only
    # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
    # different way, replace this symlink by a static file or a different symlink.
    #
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 1.1.1.1
    nameserver <router>
    # Too many DNS servers configured, the following entries may be ignored.
    nameserver 1.1.1.1
    nameserver <router>
    nameserver <vpn>
    search .

    Dagger engine:

    # This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
    # Do not edit.
    #
    # This file might be symlinked as /etc/resolv.conf. If you're looking at
    # /etc/resolv.conf and seeing this text, you have followed the symlink.
    #
    # This is a dynamic resolv.conf file for connecting local clients directly to
    # all known uplink DNS servers. This file lists all configured search domains.
    #
    # Third party programs should typically not access this file directly, but only
    # through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
    # different way, replace this symlink by a static file or a different symlink.
    #
    # See man:systemd-resolved.service(8) for details about the supported modes of
    # operation for /etc/resolv.conf.
    
    nameserver 1.1.1.1
    nameserver <router>
    # Too many DNS servers configured, the following entries may be ignored.
    nameserver 1.1.1.1
    nameserver <router>
    nameserver <vpn>
    search .

    Same outputs 🤷

  18. kema-dev commented on Feb 18, 2024

    @kema-dev

    Did some work on another project using alpine, looks like DNS servers gets me troubles too. The error seems not to be related to Dagger.

  19. marcosnils commented on Feb 28, 2024

    @marcosnils
    Contributor

    good to know @kema-dev! we're here if you need us!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions