Skip to content

Commit 29e24b2

Browse files
committed
build(cloud): private resource access (exp)
Signed-off-by: David Karlsson <[email protected]>
1 parent b1256d5 commit 29e24b2

File tree

2 files changed

+103
-13
lines changed

2 files changed

+103
-13
lines changed
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
---
2+
title: Private resources access
3+
description: Use Docker Build Cloud with private package repositories
4+
keywords: docker build build, private packages, registry, package repository, vpn, forward-hosts
5+
---
6+
7+
> **Experimental**
8+
>
9+
> This feature is experimental and subject to change without notice.
10+
{ .experimental }
11+
12+
If your builds require access to images or other packages hosted on private or
13+
on-premises artifact repositories, the builder must be able to access these
14+
resources, or the build will fail. For example, if your organization hosts a
15+
private [PyPI](https://pypi.org/) repository on a VPN, Docker Build Cloud would
16+
not be able to access it by default, since it isn't on the same network as your
17+
VPN.
18+
19+
To enable the cloud builder to access your internal resources, you can
20+
configure your Buildx client to act as a forward proxy for the builder to
21+
access your internal resources through a secure tunnel.
22+
23+
## How it works
24+
25+
When you create a cloud builder with the `forward-hosts` option, the builder
26+
uses the client as a proxy to forward requests to the specified hostnames.
27+
28+
To use this feature, you need:
29+
30+
- Docker Desktop version 4.32.0 or later (Buildx version `0.15.1-desktop.1`)
31+
32+
## Configuration
33+
34+
Connection-forwarding is configured on a per-builder and per-client basis. To
35+
enable it, set the `forward-hosts` driver option when creating the builder. For
36+
example, to create a builder that forwards connections to an internal registry
37+
on `registry.example.com:5000`, run the following command:
38+
39+
```console
40+
$ docker buildx create \
41+
--driver cloud \
42+
--driver-opt "forward-hosts=registry.example.com:5000" \
43+
<org>/<builder>
44+
```
45+
46+
Replace `registry.example.com` with the hostname of your internal registry, and
47+
`<org>/<builder>` with the namespace of your Docker organization and the name
48+
of your builder.
49+
50+
After creating the builder with the `forward-hosts` option, you can use it to
51+
build images with private packages from the hostnames you specified.
52+
53+
### Multiple hostnames
54+
55+
If you need to forward connections to multiple hostnames, specify each hostname
56+
separated by a semicolon. The following example enables forwarding for
57+
`pypi.internal` and `npm.internal`:
58+
59+
```console
60+
$ docker buildx create \
61+
--driver cloud \
62+
--driver-opt "forward-hosts=pypi.internal;npm.internal" \
63+
<org>/<builder>
64+
```
65+
66+
You can also use wildcards to forward connections for all hostnames that match
67+
a specific pattern. The following example forwards all requests to hostnames
68+
ending with `*.internal`:
69+
70+
```console
71+
$ docker buildx create \
72+
--driver cloud \
73+
--driver-opt "forward-hosts=*.internal" \
74+
<org>/<builder>
75+
```
76+
77+
To forward all hosts, use `*`:
78+
79+
```console
80+
$ docker buildx create \
81+
--driver cloud \
82+
--driver-opt "forward-hosts=*" \
83+
<org>/<builder>
84+
```
85+
86+
## Authentication
87+
88+
If your internal artifacts require authentication, make sure that you
89+
authenticate with the repository either before or during the build. For
90+
internal packages like npm or PyPI, use [build secrets](/manuals/build/building/secrets.md)
91+
to authenticate during the build. For internal OCI registries, use `docker
92+
login` to authenticate before building.
93+
94+
Note that if you use a private registry that requires authentication, you will
95+
need to authenticate with `docker login` twice before building. This is because
96+
the cloud builder needs to authenticate with Docker to use the cloud builder,
97+
and then again to authenticate with the private registry.
98+
99+
```console
100+
$ echo $DOCKER_PAT | docker login docker.io -u <username> --password-stdin
101+
$ echo $REGISTRY_PASSWORD | docker login registry.example.com -u <username> --password-stdin
102+
$ docker build --builder <cloud-builder> --tag registry.example.com/<image> --push .
103+
```

content/manuals/build-cloud/usage.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -183,16 +183,3 @@ $ docker context use default
183183

184184
This doesn't remove the builder from your system.
185185
It only changes the builder that's automatically selected to run your builds.
186-
187-
## Registries on internal networks
188-
189-
It isn't possible to use Docker Build Cloud with a private registry
190-
or registry mirror on an internal network behind a VPN.
191-
All endpoints that a cloud builder interacts with,
192-
including OCI registries, must be accessible over the internet.
193-
194-
> **Interested in trying out an experimental feature?**
195-
>
196-
>We are currently testing an experimental feature which lets cloud builders access internal resources.
197-
>
198-
> If you're interested in trying this feature, contact us using the [Support form](https://hub.docker.com/support/contact?topic=Docker+Build+Cloud&subject=Private+registry+access).

0 commit comments

Comments
 (0)