Skip to content

Commit 86b3a85

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

File tree

2 files changed

+102
-13
lines changed

2 files changed

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

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)