-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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_BUILDKIT=1 prevents custom networks using docker build --network #978
Comments
I have just stumbled across this too (running an apt_cache container locally to support my builds); believe this is intentional: this conditional pretty much says that no network modes other than |
im also looking at this one. I want to build and add to a custom network along with mongodb to run integration tests; |
I'm also very interested in this! |
any updates at this one? |
I faced this issue too when running build in Swarm from CI server. We attach to network where container with private Nuget server resides to pull required packages. |
Have run into this issue as well trying to build an image that uses a Redis instance for testing during the build process. Any updates? |
I suspect there just wasn't time/focus to implement the feature, it's marked as a roadblock item in the comment on moby/moby#40379 - if it's removed it would be a definite functional regression. |
This is a real blocker for me cause I cannot access my DNS server in another container while building. |
Any updates or workaround on this one? |
workaround: export DOCKER_BUILDKIT=0 |
@AkihiroSuda that's not really a workaround since then you cannot use the features provided by docker buildkit. Like secrets, in my case. |
This affects us as we use lots of auxiliary containers (SQL Server, Kafka, Redis) to run integration tests during builds. Without |
Since BuildKit is now enabled in docker by default we need a solution for this issue, can't use BuildKit without it :( |
@RytisLT is that true? I don't see anything indicating that, and moby/moby#40379 seems to say that BuildKit still isn't the default. |
@RytisLT yes and no. It's already the default for new installations (or after factory reset) on windows. Source: docker.com |
Another workaround, while not ideal, is to docker build --tag artifacts - <<EOF
FROM busybox
RUN set -e; \
mkdir --parents /opt/artifact; \
echo "hello world" > /opt/artifact/hello;
EXPOSE 8080
ENTRYPOINT ["httpd", "-f", "-h", "/opt/artifact", "-p", "8080"]
EOF
docker run --detach --name artifact-repo --rm --publish-all artifacts
port="$(
docker inspect \
--format '{{(index (index .NetworkSettings.Ports "8080/tcp") 0).HostPort}}' \
artifact-repo)"
docker build --tag tester - <<EOF
FROM busybox
RUN wget --output-document - http://host.docker.internal:${port}/hello
EOF
docker kill artifact-repo Gives Error response from daemon: Cannot kill container: artifact-repo: No such container: artifact-repo
Sending build context to Docker daemon 2.048kB
Step 1/4 : FROM busybox
---> 219ee5171f80
Step 2/4 : RUN set -e; mkdir --parents /opt/artifact; echo "hello world" > /opt/artifact/hello;
---> Using cache
---> 965724e107bd
Step 3/4 : EXPOSE 8080
---> Using cache
---> e39c7128ebca
Step 4/4 : ENTRYPOINT ["httpd", "-f", "-h", "/opt/artifact", "-p", "8080"]
---> Using cache
---> 7102e8ab2186
Successfully built 7102e8ab2186
Successfully tagged artifacts:latest
4696cbdd65268a55cb34ae450a8ec1e51c91bf1eaa5511ac0f4f4e515b34a958
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM busybox
---> 219ee5171f80
Step 2/2 : RUN wget --output-document - http://host.docker.internal:32774/hello
---> Running in 20c2229c7de7
Connecting to host.docker.internal:32774 (192.168.65.2:32774)
hello world
writing to stdout
- 100% |********************************| 12 0:00:00 ETA
written to stdout
Removing intermediate container 20c2229c7de7
---> 96c004a8abab
Successfully built 96c004a8abab
Successfully tagged tester:latest
artifact-repo |
To clarify, that comment refers to the following Docker for Windows 2.4.0.0 change:
However, as of version 3.2, Preferences is called Settings and this setting has no real GUI. Basically, one needs to add the following to the configuration field:
|
Considering that DOCKER_BUILDKIT=1 is now default as indicated above, it may be best to retitle this ticket to just:
Or, as this tracker is specific to Buildkit, just:
While we're at it, I do not use
It would also mitigate to improve the error message pointing to this ticket or at least clarifying what BuildKit is, or that BuildKit is optional. |
If you want to use custom docker network with buildkit use Buildkit does not depend on libnetwork, and can't see these overlay networks that are internal to docker. Instead deploy Buildkit to the same network with docker to have this behavior. |
I don't understand this... It seems to work fine on most systems, and as I understand it we aren't using any custom "network mode." It is calling the name of our external network (in the docker-compose.yml) a "network mode" - but is it really a network mode? Setting My guess is this is due to the build-time networking this needs. So does this mean no build-time networking is allowed with buildkit, or I'm just not allowed to have a custom name for such a network? @tonistiigi I'm not clear on how that could be done in a docker-compose.yml - can it? |
@dm17 it's not clear your issue is related to building an image with a custom network. Can you provide an example, commands, and output of the failing build? |
It was closed because BuildKit itself doesn't deal with the networking, per #978 (comment) and docker/buildx#175 (comment) you create a buildx instance attached to the desired custom network, and the BuildKit running in that will see your custom network. |
So it is moby that needs to support the networking that allows for this, not buildkit?
That doesn't seem to work for me. After creating the builder with the |
Yes. BuildKit is just a daemon, and the networking is supplied by the container it runs in.
I just followed up on buildx ticket where you mentioned this; I suggest a more-detailed repro, because |
Sweet, so this limitation of "no custom networks during buildtime now that docker uses buildkit" isn't necessary? :) |
The limitation is |
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974
This reverts commit 120cde8. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974
This reverts commit 120cde8. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974
This reverts commit 120cde8. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974 (cherry picked from commit 5abe9a34a123ed458bbf612983ac5634f462ffa5)
This reverts commit 120cde8. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974 (cherry picked from commit edc52c4244a3d1a34be80e18a6425d45f51dff5c)
This reverts commit ecde90e. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974
This reverts commit ecde90e. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
This reverts commit ecde90e. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974
* "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Ic6af45d28ec7d154c11f17f9f2b291e626fba928 JIRA-Ref: CMK-12974 (cherry picked from commit 5abe9a34a123ed458bbf612983ac5634f462ffa5)
This reverts commit ecde90e. * "--network" is somehow not supported by the new builder, see moby/buildkit#978 * anyway, during our builds this process does not makes much sense anymore (especially as we don't find release candidates on the download servers) * if you've used this locally, just provide the package manually Change-Id: Iab8a5a3108d84064fc14dab1e5bf44d7884d7cc0 JIRA-Ref: CMK-12974 (cherry picked from commit 1360a18886eb764b3f18279d5cfaad98aee99bbd)
Relates docker/buildx#175 |
This solution is 4 years old and still the only way I get my build process connected to my postgres container without exposing my database in production. |
I described a flow in docker/buildx#175 (comment) which should work (it worked at the time, anyway), and due to the way buildx works, any other solution to build inside a temporary custom network is going to be of roughly the same shape: |
Which mean one cannot use docker compose files - which means the code that runs and builds the containers will diverge. It seems like this is worth moving to k3s (or similar) over. |
I'm not sure what you mean by not being able to use docker compose files. If this is the combination of Docker compose and Anyway, this is still not a BuildKit issue, but a buildx issue (since we're talking about behaviours of |
Can't use docker compose files without buildx using buildkit. The point is that they caused all this divergence in our code paths for reasons they will not explain. It isn't good engineering in my opinion. If there's a reason buildkit musn't ever have built-time networking, then explain why exactly. If it can, then we can go back to the breadth of functionality we enjoyed with the classic builder and forego all of this complexity and divergence. |
To do what? Please show an example of what used to work for you, i.e. Compose file etc. and the commands you run to "use it". Right now I'm merely guessing what you're actually trying to do. Since my last guess was able to use custom networks without issues, but you're still having problems, clearly my guess was wrong and I need more details on your use-case before I can try and resolve it.
Buildkit doesn't ever have built-in networking because it has no connection to the networking. It executes containers for builds with the networking configuration that is provided to it, either by buildx/Docker, or by some other container where buildkitd is running. This has been explained multiple times in this ticket, and in docker/buildx#175, by both project leads and also me. Also, see docker/buildx#175 (comment) and in particular the final part where the setup of the in-Docker integrated version of buildkit (i.e. when it's not a daemon) is described, and how it differs from the builder which was just a direct part of Docker. |
Well, what I completely overlooked: While the builder may be running in the custom network, the build process itself still does not. For my case, I was only missing the |
Not sure if this is a Docker CLI or BuildKit issue, but when using BuildKit by specifying DOCKER_BUILDKIT=1 as part of a Docker Build in Docker v18.09, a custom Docker network is no longer recognized.
So for example, a command of "docker build --network demo-net ." will now return:
Error response from daemon: network mode "demo-net" not supported by buildkit
Seemingly this means that it only supports specific network modes are being supported, and not custom Docker networks.
The text was updated successfully, but these errors were encountered: