Skip to content

Commit 45dc847

Browse files
authored
Merge pull request #21896 from docker/published-update
publish updates from main
2 parents 38159b3 + e536caa commit 45dc847

File tree

32 files changed

+415
-64
lines changed

32 files changed

+415
-64
lines changed

content/guides/dotnet/containerize.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Let's get started!
6060

6161
? What application platform does your project use? ASP.NET Core
6262
? What's the name of your solution's main project? myWebApp
63-
? What version of .NET do you want to use? 6.0
63+
? What version of .NET do you want to use? 8.0
6464
? What local port do you want to use to access your server? 8080
6565
```
6666

content/guides/dotnet/develop.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,19 +307,19 @@ The following is the updated Dockerfile.
307307
```Dockerfile {hl_lines="10-13"}
308308
# syntax=docker/dockerfile:1
309309
310-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
310+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
311311
ARG TARGETARCH
312312
COPY . /source
313313
WORKDIR /source/src
314314
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
315315
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app
316316
317-
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS development
317+
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS development
318318
COPY . /source
319319
WORKDIR /source/src
320320
CMD dotnet run --no-launch-profile
321321
322-
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS final
322+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
323323
WORKDIR /app
324324
COPY --from=build /app .
325325
ARG UID=10001
@@ -380,7 +380,7 @@ secrets:
380380
file: db/password.txt
381381
```
382382

383-
Your containerized application will now use the `mcr.microsoft.com/dotnet/sdk:6.0-alpine` image, which includes development tools like `dotnet test`. Continue to the next section to learn how you can run `dotnet test`.
383+
Your containerized application will now use the `mcr.microsoft.com/dotnet/sdk:8.0-alpine` image, which includes development tools like `dotnet test`. Continue to the next section to learn how you can run `dotnet test`.
384384

385385
## Summary
386386

content/guides/dotnet/run-tests.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You should see output that contains the following.
3636
Starting test execution, please wait...
3737
A total of 1 test files matched the specified pattern.
3838

39-
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net6.0/tests.dll (net6.0)
39+
Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net8.0/tests.dll (net8.0)
4040
```
4141

4242
To learn more about the command, see [docker compose run](/reference/cli/docker/compose/run/).
@@ -50,20 +50,20 @@ The following is the updated Dockerfile.
5050
```dockerfile {hl_lines="9"}
5151
# syntax=docker/dockerfile:1
5252

53-
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
53+
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
5454
ARG TARGETARCH
5555
COPY . /source
5656
WORKDIR /source/src
5757
RUN --mount=type=cache,id=nuget,target=/root/.nuget/packages \
5858
dotnet publish -a ${TARGETARCH/amd64/x64} --use-current-runtime --self-contained false -o /app
5959
RUN dotnet test /source/tests
6060

61-
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS development
61+
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS development
6262
COPY . /source
6363
WORKDIR /source/src
6464
CMD dotnet run --no-launch-profile
6565

66-
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine AS final
66+
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine AS final
6767
WORKDIR /app
6868
COPY --from=build /app .
6969
ARG UID=10001
@@ -92,16 +92,16 @@ You should see output containing the following.
9292
#11 1.564 Determining projects to restore...
9393
#11 3.421 Restored /source/src/myWebApp.csproj (in 1.02 sec).
9494
#11 19.42 Restored /source/tests/tests.csproj (in 17.05 sec).
95-
#11 27.91 myWebApp -> /source/src/bin/Debug/net6.0/myWebApp.dll
96-
#11 28.47 tests -> /source/tests/bin/Debug/net6.0/tests.dll
97-
#11 28.49 Test run for /source/tests/bin/Debug/net6.0/tests.dll (.NETCoreApp,Version=v6.0)
95+
#11 27.91 myWebApp -> /source/src/bin/Debug/net8.0/myWebApp.dll
96+
#11 28.47 tests -> /source/tests/bin/Debug/net8.0/tests.dll
97+
#11 28.49 Test run for /source/tests/bin/Debug/net8.0/tests.dll (.NETCoreApp,Version=v8.0)
9898
#11 28.67 Microsoft (R) Test Execution Command Line Tool Version 17.3.3 (x64)
9999
#11 28.67 Copyright (c) Microsoft Corporation. All rights reserved.
100100
#11 28.68
101101
#11 28.97 Starting test execution, please wait...
102102
#11 29.03 A total of 1 test files matched the specified pattern.
103103
#11 32.07
104-
#11 32.08 Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net6.0/tests.dll (net6.0)
104+
#11 32.08 Passed! - Failed: 0, Passed: 1, Skipped: 0, Total: 1, Duration: < 1 ms - /source/tests/bin/Debug/net8.0/tests.dll (net8.0)
105105
#11 DONE 32.2s
106106
```
107107

content/includes/hub-limits.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
> [!NOTE]
55
>
66
> The Docker Hub plan limits will take effect on March 1, 2025. No charges on
7-
> Docker Hub image pulls or storage will be incurred between December 10, 2024,
7+
> Docker Hub pulls or storage will be incurred between December 10, 2024,
88
> and February 28, 2025.

content/manuals/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ params:
5151
description: Customize your Docker Desktop workflow.
5252
icon: extension
5353
link: /extensions/
54-
- title: Testcontainers cloud
54+
- title: Testcontainers Cloud
5555
description: Run integration tests, with real dependencies, in the cloud.
5656
icon: package_2
5757
link: https://testcontainers.com/cloud/docs/

content/manuals/billing/docker-hub-pricing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ to help you understand your storage consumption and costs.
1010

1111
> [!NOTE]
1212
>
13-
> Docker Hub plan limits will take effect on March 1, 2025. No charges on Docker Hub image pulls
13+
> Docker Hub plan limits will take effect on March 1, 2025. No charges on Docker Hub pulls
1414
or storage will be incurred from December 10, 2024 and February 28, 2025.
1515

1616
## How storage is measured

content/manuals/build/concepts/context.md

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,3 +567,193 @@ README-secret.md
567567

568568
All of the README files are included. The middle line has no effect because
569569
`!README*.md` matches `README-secret.md` and comes last.
570+
571+
## Named contexts
572+
573+
In addition to the default build context (the positional argument to the
574+
`docker build` command), you can also pass additional named contexts to builds.
575+
576+
Named contexts are specified using the `--build-context` flag, followed by a
577+
name-value pair. This lets you include files and directories from multiple
578+
sources during the build, while keeping them logically separated.
579+
580+
```console
581+
$ docker build --build-context docs=./docs .
582+
```
583+
584+
In this example:
585+
586+
- The named `docs` context points to the `./docs` directory.
587+
- The default context (`.`) points to the current working directory.
588+
589+
### Using named contexts in a Dockerfile
590+
591+
Dockerfile instructions can reference named contexts as if they are stages in a
592+
multi-stage build.
593+
594+
For example, the following Dockerfile:
595+
596+
1. Uses a `COPY` instruction to copy files from the default context into the
597+
current build stage.
598+
2. Bind mounts the files in a named context to process the files as part of the
599+
build.
600+
601+
```dockerfile
602+
# syntax=docker/dockerfile:1
603+
FROM buildbase
604+
WORKDIR /app
605+
606+
# Copy all files from the default context into /app/src in the build container
607+
COPY . /app/src
608+
RUN make bin
609+
610+
# Mount the files from the named "docs" context to build the documentation
611+
RUN --mount=from=docs,target=/app/docs \
612+
make manpages
613+
```
614+
615+
### Use cases for named contexts
616+
617+
Using named contexts allows for greater flexibility and efficiency when
618+
building Docker images. Here are some scenarios where using named contexts can
619+
be useful:
620+
621+
#### Example: combine local and remote sources
622+
623+
You can define separate named contexts for different types of sources. For
624+
example, consider a project where the application source code is local, but the
625+
deployment scripts are stored in a Git repository:
626+
627+
```console
628+
$ docker build --build-context scripts=https://github.com/user/deployment-scripts.git .
629+
```
630+
631+
In the Dockerfile, you can use these contexts independently:
632+
633+
```dockerfile
634+
# syntax=docker/dockerfile:1
635+
FROM alpine:latest
636+
637+
# Copy application code from the main context
638+
COPY . /opt/app
639+
640+
# Run deployment scripts using the remote "scripts" context
641+
RUN --mount=from=scripts,target=/scripts /scripts/main.sh
642+
```
643+
644+
#### Example: dynamic builds with custom dependencies
645+
646+
In some scenarios, you might need to dynamically inject configuration files or
647+
dependencies into the build from external sources. Named contexts make this
648+
straightforward by allowing you to mount different configurations without
649+
modifying the default build context.
650+
651+
```console
652+
$ docker build --build-context config=./configs/prod .
653+
```
654+
655+
Example Dockerfile:
656+
657+
```dockerfile
658+
# syntax=docker/dockerfile:1
659+
FROM nginx:alpine
660+
661+
# Use the "config" context for environment-specific configurations
662+
COPY --from=config nginx.conf /etc/nginx/nginx.conf
663+
```
664+
665+
#### Example: pin or override images
666+
667+
You can refer to named contexts in a Dockerfile the same way you can refer to
668+
an image. That means you can change an image reference in your Dockerfile by
669+
overriding it with a named context. For example, given the following
670+
Dockerfile:
671+
672+
```dockerfile
673+
FROM alpine:{{% param example_alpine_version %}}
674+
```
675+
676+
If you want to force image reference to resolve to a different version, without
677+
changing the Dockerfile, you can pass a context with the same name to the
678+
build. For example:
679+
680+
```console
681+
docker buildx build --build-context alpine:{{% param example_alpine_version %}}=docker-image://alpine:edge .
682+
```
683+
684+
The `docker-image://` prefix marks the context as an image reference. The
685+
reference can be a local image or an image in your registry.
686+
687+
### Named contexts with Bake
688+
689+
[Bake](/manuals/build/bake/_index.md) is a tool built into `docker build` that
690+
lets you manage your build configuration with a configuration file. Bake fully
691+
supports named contexts.
692+
693+
To define named contexts in a Bake file:
694+
695+
```hcl {title=docker-bake.hcl}
696+
target "app" {
697+
contexts = {
698+
docs = "./docs"
699+
}
700+
}
701+
```
702+
703+
This is equivalent to the following CLI invocation:
704+
705+
```console
706+
$ docker build --build-context docs=./docs .
707+
```
708+
709+
#### Linking targets with named contexts
710+
711+
In addition to making complex builds more manageable, Bake also provides
712+
additional features on top of what you can do with `docker build` on the CLI.
713+
You can use named contexts to create build pipelines, where one target depends
714+
on and builds on top of another. For example, consider a Docker build setup
715+
where you have two Dockerfiles:
716+
717+
- `base.Dockerfile`: for building a base image
718+
- `app.Dockerfile`: for building an application image
719+
720+
The `app.Dockerfile` uses the image produced by `base.Dockerfile` as it's base
721+
image:
722+
723+
```dockerfile {title=app.Dockerfile}
724+
FROM mybaseimage
725+
```
726+
727+
Normally, you would have to build the base image first, and then either load it
728+
to Docker Engine's local image store or push it to a registry. With Bake, you
729+
can reference other targets directly, creating a dependency between the `app`
730+
target and the `base` target.
731+
732+
```hcl {title=docker-bake.hcl}
733+
target "base" {
734+
dockerfile = "base.Dockerfile"
735+
}
736+
737+
target "app" {
738+
dockerfile = "app.Dockerfile"
739+
contexts = {
740+
# the target: prefix indicates that 'base' is a Bake target
741+
mybaseimage = "target:base"
742+
}
743+
}
744+
```
745+
746+
With this configuration, references to `mybaseimage` in `app.Dockerfile` use
747+
the results from building the `base` target. Building the `app` target will
748+
also trigger a rebuild of `mybaseimage`, if necessary:
749+
750+
```console
751+
$ docker buildx bake app
752+
```
753+
754+
### Further reading
755+
756+
For more information about working with named contexts, see:
757+
758+
- [`--build-context` CLI reference](/reference/cli/docker/buildx/build.md#build-context)
759+
- [Using Bake with additional contexts](/manuals/build/bake/contexts.md)

content/manuals/build/exporters/image-registry.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The following table describes the available parameters that you can pass to
3737
| `force-compression` | `true`,`false` | `false` | Forcefully apply compression, see [compression][1] |
3838
| `rewrite-timestamp` | `true`,`false` | `false` | Rewrite the file timestamps to the `SOURCE_DATE_EPOCH` value. See [build reproducibility][4] for how to specify the `SOURCE_DATE_EPOCH` value. |
3939
| `oci-mediatypes` | `true`,`false` | `false` | Use OCI media types in exporter manifests, see [OCI Media types][2] |
40+
| `oci-artifact` | `true`,`false` | `false` | Attestations are formatted as OCI artifacts, see [OCI Media types][2] |
4041
| `unpack` | `true`,`false` | `false` | Unpack image after creation (for use with containerd) |
4142
| `store` | `true`,`false` | `true` | Store the result images to the worker's (for example, containerd) image store, and ensures that the image has all blobs in the content store. Ignored if the worker doesn't have image store (when using OCI workers, for example). |
4243
| `annotation.<key>` | String | | Attach an annotation with the respective `key` and `value` to the built image,see [annotations][3] |
@@ -45,6 +46,7 @@ The following table describes the available parameters that you can pass to
4546
[2]: _index.md#oci-media-types
4647
[3]: #annotations
4748
[4]: https://github.com/moby/buildkit/blob/master/docs/build-repro.md
49+
[5]: /manuals/build/metadata/attestations/_index.md#attestations-as-oci-artifacts
4850

4951
## Annotations
5052

0 commit comments

Comments
 (0)