Skip to content

Commit bd42dac

Browse files
containers: add documentation for using external image registries (cloudflare#26364)
Adds documentation to configure ECR registries for use with containers. After setting up the registry, users will be able to use ECR images in their `wrangler.jsonc` as follows: ```json "containers": { "class_name": "MyECRContainer" "image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/image:tag" } ```
1 parent 31d16cf commit bd42dac

File tree

2 files changed

+124
-9
lines changed

2 files changed

+124
-9
lines changed

src/content/docs/containers/platform-details/image-management.mdx

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,11 @@ This is not necessary if you are using a pre-built image, as described below.
4141

4242
## Using pre-built container images
4343

44-
Currently, all images must use `registry.cloudflare.com`.
44+
Currently, we support images stored in the Cloudflare managed registry at `registry.cloudflare.com` and in [Amazon ECR](https://aws.amazon.com/ecr/).
45+
Support for additional external registries is coming soon.
4546

46-
:::note
47-
We plan to allow other image registries. Cloudflare will download your image, optionally using auth credentials,
48-
then cache it globally in the Cloudflare Registry.
49-
50-
This is not yet available.
51-
:::
52-
53-
If you wish to use a pre-built image, first, make sure it exists locally, then push it to the Cloudflare Registry:
47+
If you wish to use a pre-built image from another registry provider, first, make sure it exists locally, then
48+
push it to the Cloudflare Registry:
5449

5550
```
5651
docker pull <public-image>
@@ -88,6 +83,65 @@ This will output an image registry URI that you can then use in your Wrangler co
8883

8984
</WranglerConfig>
9085

86+
### Using Amazon ECR container images
87+
88+
To use container images stored in [Amazon ECR](https://aws.amazon.com/ecr/), you will need to configure the ECR registry domain with credentials.
89+
These credentials get stored in [Secrets Store](/secrets-store) under the `containers` scope.
90+
When we prepare your container, these credentials will be used to generate an ephemeral token that can pull your image.
91+
We do not currently support public ECR images.
92+
To generate the necessary credentials for ECR, you will need to create an IAM user with a read-only policy.
93+
The following example grants access to all image repositories under AWS account `123456789012` in `us-east-1`.
94+
95+
```json
96+
{
97+
"Version": "2012-10-17",
98+
"Statement": [
99+
{
100+
"Action": ["ecr:GetAuthorizationToken"],
101+
"Effect": "Allow",
102+
"Resource": "*"
103+
},
104+
{
105+
"Effect": "Allow",
106+
"Action": [
107+
"ecr:BatchCheckLayerAvailability",
108+
"ecr:GetDownloadUrlForLayer",
109+
"ecr:BatchGetImage"
110+
],
111+
// arn:${Partition}:ecr:${Region}:${Account}:repository/${Repository-name}
112+
"Resource": [
113+
"arn:aws:ecr:us-east-1:123456789012:repository/*"
114+
// "arn:aws:ecr:us-east-1:123456789012:repository/example-repo"
115+
]
116+
}
117+
]
118+
}
119+
```
120+
121+
You can then use the credentials for the IAM User to [configure a registry in Wrangler](/workers/wrangler/commands/#containers-registries).
122+
Wrangler will prompt you to create a Secrets Store store if one does not already exist, and then create your secret.
123+
124+
<PackageManagers
125+
type="exec"
126+
pkg="wrangler"
127+
args="containers registries configure 123456789012.dkr.ecr.us-east-1.amazonaws.com --aws-access-key-id=AKIAIOSFODNN7EXAMPLE"
128+
/>
129+
130+
Once this is setup, you will be able to use ECR images in your wrangler config.
131+
132+
<WranglerConfig>
133+
134+
```json
135+
{
136+
"containers": {
137+
"image": "123456789012.dkr.ecr.us-east-1.amazonaws.com/example-repo:tag"
138+
// ...rest of config...
139+
}
140+
}
141+
```
142+
143+
</WranglerConfig>
144+
91145
:::note
92146
Currently, the Cloudflare Vite-plugin does not support registry links in local development, unlike `wrangler dev`.
93147
As a workaround, you can create a minimal Dockerfile that uses `FROM <registry-link>`. Make sure to `EXPOSE` a port in local dev as well.

src/content/partials/workers/wrangler-commands/containers.mdx

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,67 @@ wrangler containers images delete [IMAGE] [OPTIONS]
6767
- `IMAGE` <Type text="string" /> <MetaInfo text="required" />
6868
- Image to delete of the form `IMAGE:TAG`
6969

70+
<AnchorHeading title="`registries`" slug="containers-registries" depth={3} />
71+
72+
Configure and view registries available to your container.
73+
[Read more](/containers/platform-details/image-management/#using-amazon-ecr-container-images) about our currently supported external registries.
74+
75+
<AnchorHeading
76+
title="`registries list`"
77+
slug="containers-registries-list"
78+
depth={4}
79+
/>
80+
81+
List registries your containers are able to use.
82+
83+
```txt
84+
wrangler containers registries list [OPTIONS]
85+
```
86+
87+
- `--json` <Type text="boolean" /> <MetaInfo text="optional" />
88+
- Return output as clean JSON.
89+
- Default: false
90+
91+
<AnchorHeading
92+
title="`registries configure`"
93+
slug="containers-registries-configure"
94+
depth={4}
95+
/>
96+
97+
Configure a new registry for your account.
98+
99+
```txt
100+
wrangler containers registries configure [DOMAIN] [OPTIONS]
101+
```
102+
103+
- `DOMAIN` <Type text="string" /> <MetaInfo text="required" />
104+
- domain to configre for the registry
105+
- `--public-credential` <Type text="string" /> <MetaInfo text="required" />
106+
- The public part of the registry credentials, e.g. `AWS_ACCESS_KEY_ID` for ECR
107+
- `--secret-store-id` <Type text="string" /> <MetaInfo text="optional" />
108+
- The ID of the secret store to use to store the registry credentials
109+
- `--secret-name` <Type text="string" /> <MetaInfo text="optional" />
110+
- The name Wrangler should store the registry credentials under
111+
112+
When run interactively, wrangler will prompt you for your secret and store it in Secrets Store.
113+
To run non-interactively, you can send your secret value to wrangler through stdin to have
114+
the secret created for you.
115+
116+
<AnchorHeading
117+
title="`registries delete`"
118+
slug="containers-registries-delete"
119+
depth={4}
120+
/>
121+
122+
Remove a registry configuration from your account.
123+
124+
```txt
125+
wrangler containers registries delete [DOMAIN] [OPTIONS]
126+
```
127+
128+
- `DOMAIN` <Type text="string" /> <MetaInfo text="required" />
129+
- domain of the registry to delete
130+
70131
<AnchorHeading title="`info`" slug="containers-info" depth={3} />
71132

72133
Get information about a specific Container, including top-level details and a list of instances.

0 commit comments

Comments
 (0)