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

Name resolution in custom network doesn't work during build #2306

Open
3 tasks done
juansebastianl opened this issue Mar 5, 2024 · 1 comment
Open
3 tasks done

Name resolution in custom network doesn't work during build #2306

juansebastianl opened this issue Mar 5, 2024 · 1 comment

Comments

@juansebastianl
Copy link

juansebastianl commented Mar 5, 2024

Contributing guidelines

I've found a bug and checked that ...

  • ... the documentation does not mention anything about my problem
  • ... there are no open or closed issues that are related to my problem

Description

I've got a builder with a custom network with other docker containers attached, during build I have a RUN curl http://my-other-container and I get a Not Found error. The curl works after the container is built and run, as well as in the builder container, but not during the build.

Expected behaviour

I start with a custom network my-network which has my-other-container attached to it.

I create a custom builder

docker buildx create --use \
        --name custom_network_builder \
        --driver docker-container \
        --driver-opt "network=my-network"

and then build my Dockerfile

docker build --builder=custom_network_builder --load -f ./Dockerfile

where my dockerfile is

FROM ubuntu:focal
RUN curl http://my-other-container

then my docker container should build successfully.

Actual behaviour

I get a Could not resolve: my-other-container error from curl and the build fails. I have done docker excec -it buildx_build_container bash and tried the curl and it works as expected. I have also done the curl from the docker container once it is built (after taking the RUN step out) and it works fine as well.

Buildx version

github.com/docker/buildx v0.11.2 9872040

Docker info

No response

Builders list

NAME/NODE DRIVER/ENDPOINT STATUS  BUILDKIT             PLATFORMS
default * docker
  default default         running v0.11.7+d3e6c1360f6e linux/amd64, linux/amd64/v2, linux/amd64/v3, linux/386

Configuration

FROM ubuntu:focal
RUN curl http://my-other-container
docker build --builder=custom_network_builder --load -f ./Dockerfile

Build logs

No response

Additional info

No response

@tonistiigi
Copy link
Member

I believe this has been fixed in buildkit v0.13.0 but you need to use --network=host (that effectively means network of your builder container) so that the RUN commands don't use their own (potentially) isolated network.

moby/buildkit#4524

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

2 participants