Skip to content

Commit d138815

Browse files
committed
docs(ci): clarify builder and credential variables for CI setup (DCL-248)
1 parent f830087 commit d138815

File tree

2 files changed

+64
-53
lines changed

2 files changed

+64
-53
lines changed

content/manuals/build-cloud/ci.md

Lines changed: 51 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -36,42 +36,42 @@ See [Loading build results](./usage/#loading-build-results) for details.
3636

3737
To enable your CI/CD system to build and push images using Docker Build Cloud, provide both an access token and a username. The type of token and the username you use depend on your account type and permissions.
3838

39-
- If you are an organization administrator or have permission to create [organization access tokens (OAT)](../security/for-admins/access-tokens.md), use an OAT and set `DOCKER_USER` to your Docker Hub organization name.
40-
- If you do not have permission to create OATs or are using a personal account, use a [personal access token (PAT)](/security/for-developers/access-tokens/) and set `DOCKER_USER` to your Docker Hub username.
39+
- If you are an organization administrator or have permission to create [organization access tokens (OAT)](../security/for-admins/access-tokens.md), use an OAT and set `DOCKER_ACCOUNT` to your Docker Hub organization name.
40+
- If you do not have permission to create OATs or are using a personal account, use a [personal access token (PAT)](/security/for-developers/access-tokens/) and set `DOCKER_ACCOUNT` to your Docker Hub username.
4141

4242
### Creating access tokens
4343

4444
#### For organization accounts
4545

4646
If you are an organization administrator:
4747

48-
1. Create an [organization access token (OAT)](../security/for-admins/access-tokens.md):
49-
- The token must have these permissions:
50-
- **cloud-connect** scope
51-
- **Read public repositories** permission
52-
- **Repository access** with **Image push** permission for the target repository:
53-
- Expand the **Repository** drop-down.
54-
- Select **Add repository** and choose your target repository.
55-
- Set the **Image push** permission for the repository.
48+
- Create an [organization access token (OAT)](../security/for-admins/access-tokens.md). The token must have these permissions:
49+
1. **cloud-connect** scope
50+
2. **Read public repositories** permission
51+
3. **Repository access** with **Image push** permission for the target repository:
52+
- Expand the **Repository** drop-down.
53+
- Select **Add repository** and choose your target repository.
54+
- Set the **Image push** permission for the repository.
5655

5756
If you are not an organization administrator:
5857

5958
- Ask your organization administrator for an access token with the permissions listed above, or use a personal access token.
6059

6160
#### For personal accounts
6261

63-
1. Create a [personal access token (PAT)](/security/for-developers/access-tokens/):
64-
- Create a new token with **Read & write** access.
65-
- Note: Building with Docker Build Cloud only requires read access, but you need write access to push images to a Docker Hub repository.
62+
- Create a [personal access token (PAT)](/security/for-developers/access-tokens/) with the following permissions:
63+
1. **Read & write** access.
64+
- Note: Building with Docker Build Cloud only requires read access, but you need write access to push images to a Docker Hub repository.
6665

6766

6867
## CI platform examples
6968

7069
> [!NOTE]
7170
>
72-
> In your CI/CD configuration, set the following variables:
73-
> - `DOCKER_PAT` — your access token (PAT or OAT)
74-
> - `DOCKER_USER` — your Docker Hub username (for PAT) or organization name (for OAT)
71+
> In your CI/CD configuration, set the following variables/secrets:
72+
> - `DOCKER_ACCESS_TOKEN` — your access token (PAT or OAT). Use a secret to store the token.
73+
> - `DOCKER_ACCOUNT` — your Docker Hub organization name (for OAT) or username (for PAT)
74+
> - `CLOUD_BUILDER_NAME` — the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
7575
>
7676
> This ensures your builds authenticate correctly with Docker Build Cloud.
7777
@@ -92,20 +92,20 @@ jobs:
9292
- name: Login to Docker Hub
9393
uses: docker/login-action@v3
9494
with:
95-
username: ${{ vars.DOCKER_USER }}
96-
password: ${{ secrets.DOCKER_PAT }}
95+
username: ${{ vars.DOCKER_ACCOUNT }}
96+
password: ${{ secrets.DOCKER_ACCESS_TOKEN }}
9797

9898
- name: Set up Docker Buildx
9999
uses: docker/setup-buildx-action@v3
100100
with:
101101
driver: cloud
102-
endpoint: "<ORG>/default"
102+
endpoint: "${{ vars.DOCKER_ACCOUNT }}/${{ vars.CLOUD_BUILDER_NAME }}" # for example, "acme/default"
103103
install: true
104104

105105
- name: Build and push
106106
uses: docker/build-push-action@v6
107107
with:
108-
tags: "<IMAGE>"
108+
tags: "<IMAGE>" # for example, "acme/my-image:latest"
109109
# For pull requests, export results to the build cache.
110110
# Otherwise, push to a registry.
111111
outputs: ${{ github.event_name == 'pull_request' && 'type=cacheonly' || 'type=registry' }}
@@ -120,19 +120,20 @@ default:
120120
- docker:24-dind
121121
before_script:
122122
- docker info
123-
- echo "$DOCKER_PAT" | docker login --username "$DOCKER_USER" --password-stdin
123+
- echo "$DOCKER_ACCESS_TOKEN" | docker login --username "$DOCKER_ACCOUNT" --password-stdin
124124
- |
125125
apk add curl jq
126126
ARCH=${CI_RUNNER_EXECUTABLE_ARCH#*/}
127127
BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$ARCH\"))")
128128
mkdir -vp ~/.docker/cli-plugins/
129129
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
130130
chmod a+x ~/.docker/cli-plugins/docker-buildx
131-
- docker buildx create --use --driver cloud ${DOCKER_ORG}/default
131+
- docker buildx create --use --driver cloud ${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}
132132

133133
variables:
134134
IMAGE_NAME: <IMAGE>
135-
DOCKER_ORG: <ORG>
135+
DOCKER_ACCOUNT: <DOCKER_ACCOUNT> # your Docker Hub organization name (or username when using a personal account)
136+
CLOUD_BUILDER_NAME: <CLOUD_BUILDER_NAME> # the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
136137

137138
# Build multi-platform image and push to a registry
138139
build_push:
@@ -176,8 +177,8 @@ jobs:
176177
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
177178
chmod a+x ~/.docker/cli-plugins/docker-buildx
178179
179-
- run: echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin
180-
- run: docker buildx create --use --driver cloud "<ORG>/default"
180+
- run: echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ --password-stdin
181+
- run: docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
181182

182183
- run: |
183184
docker buildx build \
@@ -199,8 +200,8 @@ jobs:
199200
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
200201
chmod a+x ~/.docker/cli-plugins/docker-buildx
201202
202-
- run: echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin
203-
- run: docker buildx create --use --driver cloud "<ORG>/default"
203+
- run: echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ --password-stdin
204+
- run: docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
204205

205206
- run: |
206207
docker buildx build \
@@ -231,24 +232,25 @@ Add the following `environment` hook agent's hook directory:
231232
set -euo pipefail
232233
233234
if [[ "$BUILDKITE_PIPELINE_NAME" == "build-push-docker" ]]; then
234-
export DOCKER_PAT="<DOCKER_PERSONAL_ACCESS_TOKEN>"
235+
export DOCKER_ACCESS_TOKEN="<DOCKER_ACCESS_TOKEN>"
235236
fi
236237
```
237238

238239
Create a `pipeline.yml` that uses the `docker-login` plugin:
239240

240241
```yaml
241242
env:
242-
DOCKER_ORG: <ORG>
243+
DOCKER_ACCOUNT: <DOCKER_ACCOUNT> # your Docker Hub organization name (or username when using a personal account)
244+
CLOUD_BUILDER_NAME: <CLOUD_BUILDER_NAME> # the name of the cloud builder you created in the [Docker Build Cloud Dashboard](https://app.docker.com/build/)
243245
IMAGE_NAME: <IMAGE>
244246
245247
steps:
246248
- command: ./build.sh
247249
key: build-push
248250
plugins:
249251
- docker-login#v2.1.0:
250-
username: <DOCKER_USER>
251-
password-env: DOCKER_PAT # the variable name in the environment hook
252+
username: DOCKER_ACCOUNT
253+
password-env: DOCKER_ACCESS_TOKEN # the variable name in the environment hook
252254
```
253255

254256
Create the `build.sh` script:
@@ -277,7 +279,7 @@ curl --silent -L --output $DOCKER_DIR/cli-plugins/docker-buildx $BUILDX_URL
277279
chmod a+x ~/.docker/cli-plugins/docker-buildx
278280

279281
# Connect to your builder and set it as the default builder
280-
docker buildx create --use --driver cloud "$DOCKER_ORG/default"
282+
docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
281283

282284
# Cache-only image build
283285
docker buildx build \
@@ -302,9 +304,9 @@ pipeline {
302304
303305
environment {
304306
ARCH = 'amd64'
305-
DOCKER_PAT = credentials('docker-personal-access-token')
306-
DOCKER_USER = credentials('docker-username')
307-
DOCKER_ORG = '<ORG>'
307+
DOCKER_ACCESS_TOKEN = credentials('docker-access-token')
308+
DOCKER_ACCOUNT = credentials('docker-account')
309+
CLOUD_BUILDER_NAME = '<CLOUD_BUILDER_NAME>'
308310
IMAGE_NAME = '<IMAGE>'
309311
}
310312
@@ -317,8 +319,8 @@ pipeline {
317319
sh 'mkdir -vp ~/.docker/cli-plugins/'
318320
sh 'curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL'
319321
sh 'chmod a+x ~/.docker/cli-plugins/docker-buildx'
320-
sh 'echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin'
321-
sh 'docker buildx create --use --driver cloud "$DOCKER_ORG/default"'
322+
sh 'echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ACCOUNT --password-stdin'
323+
sh 'docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"'
322324
// Cache-only build
323325
sh 'docker buildx build --platform linux/amd64,linux/arm64 --tag "$IMAGE_NAME" --output type=cacheonly .'
324326
// Build and push a multi-platform image
@@ -340,18 +342,18 @@ services:
340342

341343
env:
342344
global:
343-
- IMAGE_NAME=username/repo
345+
- IMAGE_NAME=<IMAGE> # for example, "acme/my-image:latest"
344346

345347
before_install: |
346-
echo "$DOCKER_PAT" | docker login --username "$DOCKER_USER" --password-stdin
348+
echo "$DOCKER_ACCESS_TOKEN" | docker login --username "$DOCKER_ACCOUNT" --password-stdin
347349
348350
install: |
349351
set -e
350352
BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$TRAVIS_CPU_ARCH\"))")
351353
mkdir -vp ~/.docker/cli-plugins/
352354
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
353355
chmod a+x ~/.docker/cli-plugins/docker-buildx
354-
docker buildx create --use --driver cloud "<ORG>/default"
356+
docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
355357
356358
script: |
357359
docker buildx build \
@@ -363,9 +365,8 @@ script: |
363365
### BitBucket Pipelines
364366
365367
```yaml
366-
# Prerequisites: $DOCKER_USER, $DOCKER_PAT setup as deployment variables
368+
# Prerequisites: $DOCKER_ACCOUNT, $CLOUD_BUILDER_NAME, $DOCKER_ACCESS_TOKEN setup as deployment variables
367369
# This pipeline assumes $BITBUCKET_REPO_SLUG as the image name
368-
# Replace <ORG> in the `docker buildx create` command with your Docker org
369370

370371
image: atlassian/default-image:3
371372

@@ -379,8 +380,8 @@ pipelines:
379380
- BUILDX_URL=$(curl -s https://raw.githubusercontent.com/docker/actions-toolkit/main/.github/buildx-lab-releases.json | jq -r ".latest.assets[] | select(endswith(\"linux-$ARCH\"))")
380381
- curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
381382
- chmod a+x ~/.docker/cli-plugins/docker-buildx
382-
- echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin
383-
- docker buildx create --use --driver cloud "<ORG>/default"
383+
- echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ACCOUNT --password-stdin
384+
- docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
384385
- IMAGE_NAME=$BITBUCKET_REPO_SLUG
385386
- docker buildx build
386387
--platform linux/amd64,linux/arm64
@@ -404,11 +405,11 @@ mkdir -vp ~/.docker/cli-plugins/
404405
curl --silent -L --output ~/.docker/cli-plugins/docker-buildx $BUILDX_URL
405406
chmod a+x ~/.docker/cli-plugins/docker-buildx
406407

407-
# Login to Docker Hub. For security reasons $DOCKER_PAT should be a Personal Access Token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
408-
echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin
408+
# Login to Docker Hub with an access token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
409+
echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ACCOUNT --password-stdin
409410

410411
# Connect to your builder and set it as the default builder
411-
docker buildx create --use --driver cloud "<ORG>/default"
412+
docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
412413

413414
# Cache-only image build
414415
docker buildx build \
@@ -449,11 +450,11 @@ curl --silent -L --output ~/.docker/cli-plugins/docker-compose $COMPOSE_URL
449450
chmod a+x ~/.docker/cli-plugins/docker-buildx
450451
chmod a+x ~/.docker/cli-plugins/docker-compose
451452

452-
# Login to Docker Hub. For security reasons $DOCKER_PAT should be a Personal Access Token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
453-
echo "$DOCKER_PAT" | docker login --username $DOCKER_USER --password-stdin
453+
# Login to Docker Hub with an access token. See https://docs.docker.com/build-cloud/ci/#creating-access-tokens
454+
echo "$DOCKER_ACCESS_TOKEN" | docker login --username $DOCKER_ACCOUNT --password-stdin
454455

455456
# Connect to your builder and set it as the default builder
456-
docker buildx create --use --driver cloud "<ORG>/default"
457+
docker buildx create --use --driver cloud "${DOCKER_ACCOUNT}/${CLOUD_BUILDER_NAME}"
457458

458459
# Build the image build
459460
docker compose build

content/manuals/build-cloud/setup.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ environment.
1616
To get started with Docker Build Cloud, you need to:
1717

1818
- Download and install Docker Desktop version 4.26.0 or later.
19-
- Sign up for a Docker Build Cloud subscription in the [Docker Build Cloud Dashboard](https://app.docker.com/build/).
19+
- Create a cloud builder on the [Docker Build Cloud Dashboard](https://app.docker.com/build/).
20+
- When you create the builder, choose a name for it (for example, `default`). You will use this name as `BUILDER_NAME` in the CLI steps below.
2021

2122
### Use Docker Build Cloud without Docker Desktop
2223

@@ -50,9 +51,18 @@ command, or using the Docker Desktop settings GUI.
5051
$ docker buildx create --driver cloud <ORG>/<BUILDER_NAME>
5152
```
5253

53-
Replace `ORG` with the Docker Hub namespace of your Docker organization.
54+
Replace `<ORG>` with the Docker Hub namespace of your Docker organization (or your username if you are using a personal account), and `<BUILDER_NAME>` with the name you chose when creating the builder in the dashboard.
55+
56+
This creates a local instance of the cloud builder named `cloud-ORG-BUILDER_NAME`.
57+
58+
> [!NOTE]
59+
> Example:
60+
>
61+
> If your organization is `acme` and you named your builder `default`, use:
62+
> ```console
63+
> $ docker buildx create --driver cloud acme/default
64+
> ```
5465
55-
This creates a builder named `cloud-ORG-BUILDER_NAME`.
5666
5767
{{< /tab >}}
5868
{{< tab name="Docker Desktop" >}}

0 commit comments

Comments
 (0)