Commit graph

46171 commits

Author SHA1 Message Date
Bjorn Neergaard
6285ec378c
Merge pull request #45782 from thaJeztah/24.0_backport_reserve_once
[24.0 backport] daemon: registerName(): don't reserve name twice
2023-06-21 09:12:39 -06:00
Sebastiaan van Stijn
aaa8a90747
Merge pull request #45780 from neersighted/backport/45698/24.0 2023-06-21 17:00:44 +02:00
Sebastiaan van Stijn
6776279896
daemon: registerName(): don't reserve name twice
daemon.generateNewName() already reserves the generated name, but its name
did not indicate it did. The daemon.registerName() assumed that the generated
name still had to be reserved, which could mean it would try to reserve the
same name again.

This patch renames daemon.generateNewName to daemon.generateAndReserveName
to make it clearer what it does, and updates registerName() to return early
if it successfully generated (and registered) the container name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 3ba67ee214)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-20 23:48:45 +02:00
Djordje Lukic
aec7a80c6f
c8d: Use reference counting while mounting a snapshot
Some snapshotters (like overlayfs or zfs) can't mount the same
directories twice. For example if the same directroy is used as an upper
directory in two mounts the kernel will output this warning:

    overlayfs: upperdir is in-use as upperdir/workdir of another mount, accessing files from both mounts will result in undefined behavior.

And indeed accessing the files from both mounts will result in an "No
such file or directory" error.

This change introduces reference counts for the mounts, if a directory
is already mounted the mount interface will only increment the mount
counter and return the mount target effectively making sure that the
filesystem doesn't end up in an undefined behavior.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit 32d58144fd)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-06-20 12:54:03 -06:00
Sebastiaan van Stijn
d7aa1e14e5
Merge pull request #45771 from thaJeztah/24.0_backport_fix_docker_py
[24.0 backport] testing: temporarily pin docker-py tests to use "bullseye"
2023-06-20 18:20:00 +02:00
Sebastiaan van Stijn
5652c59647
testing: temporarily pin docker-py tests to use "bullseye"
The official Python images on Docker Hub switched to debian bookworm,
which is now the current stable version of Debian.

However, the location of the apt repository config file changed, which
causes the Dockerfile build to fail;

    Loaded image: emptyfs:latest
    Loaded image ID: sha256:0df1207206e5288f4a989a2f13d1f5b3c4e70467702c1d5d21dfc9f002b7bd43
    INFO: Building docker-sdk-python3:5.0.3...
    tests/Dockerfile:6
    --------------------
       5 |     ARG APT_MIRROR
       6 | >>> RUN sed -ri "s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g" /etc/apt/sources.list \
       7 | >>>     && sed -ri "s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g" /etc/apt/sources.list
       8 |
    --------------------
    ERROR: failed to solve: process "/bin/sh -c sed -ri \"s/(httpredir|deb).debian.org/${APT_MIRROR:-deb.debian.org}/g\" /etc/apt/sources.list     && sed -ri \"s/(security).debian.org/${APT_MIRROR:-security.debian.org}/g\" /etc/apt/sources.list" did not complete successfully: exit code: 2

This needs to be fixed in docker-py, but in the meantime, we can pin to
the bullseye variant.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 19d860fa9d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-20 11:41:20 +02:00
Bjorn Neergaard
458af2b1e0
Merge pull request #45747 from thaJeztah/24.0_backport_rootlesskit_v1.1.1
[24.0 backport] Rootlesskit v1.1.1
2023-06-15 09:52:27 -06:00
Sebastiaan van Stijn
58729344aa
Merge pull request #45745 from thaJeztah/24.0_backport_update_go_1.20.5
[24.0 backport] update go to go1.20.5
2023-06-14 22:20:22 +02:00
Bjorn Neergaard
3d96894184
Merge pull request #45748 from thaJeztah/24.0_backport_copy_uidgid
[24.0 backport] fix docker cp -a failing to access / in container (run `getent` with a noop stdin)
2023-06-14 10:09:30 -06:00
Nicolas De Loof
789a8755b8
run getent with a noop stdin
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
(cherry picked from commit 3cc5d62f8a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-14 13:12:00 +02:00
Jan Garcia
f7298b326e
vendor: github.com/sirupsen/logrus v1.9.3
Signed-off-by: Jan Garcia <github-public@n-garcia.com>
(cherry picked from commit 197b0b16e3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-14 13:08:58 +02:00
Jan Garcia
1c18ad6ca6
vendor: github.com/rootless-containers/rootlesskit v1.1.1
Signed-off-by: Jan Garcia <github-public@n-garcia.com>
(cherry picked from commit 8c4dfc9e6a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-14 13:07:32 +02:00
Jan Garcia
ae4a10df67
update RootlessKit to v1.1.1
Signed-off-by: Jan Garcia <github-public@n-garcia.com>
(cherry picked from commit 0b1c1877c5)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-14 13:05:04 +02:00
Sebastiaan van Stijn
24c882c3e0
update go to go1.20.5
go1.20.5 (released 2023-06-06) includes four security fixes to the cmd/go and
runtime packages, as well as bug fixes to the compiler, the go command, the
runtime, and the crypto/rsa, net, and os packages. See the Go 1.20.5 milestone
on our issue tracker for details:

https://github.com/golang/go/issues?q=milestone%3AGo1.20.5+label%3ACherryPickApproved

full diff: https://github.com/golang/go/compare/go1.20.4...go1.20.5

These minor releases include 3 security fixes following the security policy:

- cmd/go: cgo code injection
  The go command may generate unexpected code at build time when using cgo. This
  may result in unexpected behavior when running a go program which uses cgo.

  This may occur when running an untrusted module which contains directories with
  newline characters in their names. Modules which are retrieved using the go command,
  i.e. via "go get", are not affected (modules retrieved using GOPATH-mode, i.e.
  GO111MODULE=off, may be affected).

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2023-29402 and Go issue https://go.dev/issue/60167.

- runtime: unexpected behavior of setuid/setgid binaries

  The Go runtime didn't act any differently when a binary had the setuid/setgid
  bit set. On Unix platforms, if a setuid/setgid binary was executed with standard
  I/O file descriptors closed, opening any files could result in unexpected
  content being read/written with elevated prilieges. Similarly if a setuid/setgid
  program was terminated, either via panic or signal, it could leak the contents
  of its registers.

  Thanks to Vincent Dehors from Synacktiv for reporting this issue.

  This is CVE-2023-29403 and Go issue https://go.dev/issue/60272.

- cmd/go: improper sanitization of LDFLAGS

  The go command may execute arbitrary code at build time when using cgo. This may
  occur when running "go get" on a malicious module, or when running any other
  command which builds untrusted code. This is can by triggered by linker flags,
  specified via a "#cgo LDFLAGS" directive.

  Thanks to Juho Nurminen of Mattermost for reporting this issue.

  This is CVE-2023-29404 and CVE-2023-29405 and Go issues https://go.dev/issue/60305 and https://go.dev/issue/60306.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 98a44bb18e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-14 12:48:57 +02:00
Akihiro Suda
03a0ee4202
Merge pull request #45699 from vvoland/dockerfile-separate-cli-2-24
[24.0 backport] Dockerfile: Use separate cli for shell and integration-cli
2023-06-12 21:53:14 +09:00
Sebastiaan van Stijn
df620567eb
Merge pull request #45708 from neersighted/check_config_bpf/24.0
[24.0 backport] contrib/check-config: require xt_bpf for encrypted overlay
2023-06-07 13:54:38 +02:00
Bjorn Neergaard
b3133d7471
contrib/check-config: move xt_bpf check to overlay section
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
(cherry picked from commit 800ea039ec)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-06-06 16:48:55 -06:00
Bjorn Neergaard
8c552012ae
contrib/check-config: check for xt_bpf
We omit xt_u32 as it's optional; since we will remove support for this
module in the future, it's simpler to check for xt_bpf, which will
become the new baseline.

Related issues:
* https://github.com/microsoft/WSL/issues/10029#issuecomment-1574440255
* https://github.com/docker/for-win/issues/13450#issuecomment-1574443139

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
(cherry picked from commit 1910fdde81)
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-06-06 16:48:50 -06:00
Paweł Gronowski
61d547fd06
Dockerfile: Move dockercli to base-dev
Avoids invalidation of dev-systemd-true and dev-base when changing the
CLI version/repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 0f9c8e684a)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-05 17:03:27 +02:00
Paweł Gronowski
e5fbc3f75a
hack/cli.sh: Quiet origin cleanup
Don't show `error: No such remote: 'origin'` error when building for the
first time and the cached git repository doesn't a remote yet.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 5433b88e2d)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-05 17:03:25 +02:00
Paweł Gronowski
1a078977e1
Dockerfile/shell: Install buildx cli plugin
Installs the buildx cli plugin in the container shell by default.
Previously user had to manually download the buildx binary to use
buildkit.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 49f76a34b5)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-05 16:47:18 +02:00
Paweł Gronowski
c4198e6053
Dockerfile: Use separate cli for shell and integration-cli
Use separate cli for integration-cli to allow use newer CLI for
interactive dev shell usage.

Both versions can be overriden with DOCKERCLI_VERSION or
DOCKERCLI_INTEGRATION_VERSION. Binary is downloaded from
download.docker.com if it's available, otherwise it's built from the
source.

For backwards compatibility DOCKER_CLI_PATH overrides BOTH clis.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 17c99f7164)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-05 16:47:16 +02:00
Bjorn Neergaard
8e70a1b23e
Merge pull request #45692 from vvoland/builder-use-moby-exporter-by-default-24
[backport 24.0] builder-next: Set moby exporter as default
2023-06-02 09:22:02 -06:00
Bjorn Neergaard
c671434cd2
Merge pull request #45688 from vvoland/c8d-load-unpack-attestation-24
[24.0 backport] c8d/load: Don't unpack pseudo images
2023-06-02 08:28:20 -06:00
Paweł Gronowski
647ba03224
builder-next: Set moby exporter as default
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit d63569c73d)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 16:06:11 +02:00
Sebastiaan van Stijn
2f65bb7bb5
Merge pull request #45685 from thaJeztah/24.0_backport_dockerfile_more_link
[24.0 backport] Dockerfile: use COPY --link for source code as well
2023-06-02 15:12:05 +02:00
Paweł Gronowski
961fe27408
c8d/handlers: Handle error in walkPresentChildren
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 4295806736)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 15:09:28 +02:00
Paweł Gronowski
087cf6f238
c8d/load: Don't unpack pseudo images
Don't unpack image manifests which are not a real images that can't be
unpacked.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 4d3238dc0b)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 15:09:25 +02:00
Paweł Gronowski
0b9d68f59d
c8d/load: Use walkImageManifests
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit b08bff8ba3)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 15:09:24 +02:00
Paweł Gronowski
cbf0779bfc
c8d/list: Use walkImageManifests
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 5210f48bfc)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 15:09:22 +02:00
Paweł Gronowski
0139309fef
c8d: Add walkImageManifests and ImageManifest wrapper
The default implementation of the containerd.Image interface provided by
the containerd operates on the parent index/manifest list of the image
and the platform matcher.

This isn't convenient when a specific manifest is already known and it's
redundant to search the whole index for a manifest that matches the
given platform matcher. It can also result in a different manifest
picked up than expected when multiple manifests with the same platform
are present.

This introduces a walkImageManifests which walks the provided image and
calls a handler with a ImageManifest, which is a simple wrapper that
implements containerd.Image interfaces and performs all containerd.Image
operations against a platform specific manifest instead of the root
manifest list/index.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit fabc1d5bef)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-06-02 15:09:20 +02:00
Sebastiaan van Stijn
18278d3dc1
Merge pull request #45684 from thaJeztah/24.0_backport_c8d_useragent_more_details
[24.0 backport] containerd: add c8d version and storage-driver to User-Agent
2023-06-02 14:35:21 +02:00
Sebastiaan van Stijn
e1c7956764
Dockerfile: use COPY --link for source code as well
I missed the most important COPY in 637ca59375

Copying the source code into the dev-container does not depend on the parent
layers, so can use the --link option as well.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit ff2342154b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 13:22:05 +02:00
Sebastiaan van Stijn
4b3329d3dd
Merge pull request #45678 from thaJeztah/24.0_backport_fix_snapshotter_change
[24.0 backport] Make sure the image is unpacked for the current snapshotter
2023-06-02 13:17:54 +02:00
Sebastiaan van Stijn
32d442aee1
Merge pull request #45672 from thaJeztah/24.0_backport_bump_zfs
[24.0 backport] vendor: github.com/mistifyio/go-zfs/v3 v3.0.1
2023-06-02 11:48:36 +02:00
Sebastiaan van Stijn
75afe3201b
containerd: add c8d version and storage-driver to User-Agent
With this patch, the user-agent has information about the containerd-client
version and the storage-driver that's used when using the containerd-integration;

    time="2023-06-01T11:27:07.959822887Z" level=info msg="listening on [::]:5000" go.version=go1.19.9 instance.id=53590f34-096a-4fd1-9c58-d3b8eb7e5092 service=registry version=2.8.2
    ...
    172.18.0.1 - - [01/Jun/2023:11:30:12 +0000] "HEAD /v2/multifoo/blobs/sha256:c7ec7661263e5e597156f2281d97b160b91af56fa1fd2cc045061c7adac4babd HTTP/1.1" 404 157 "" "docker/dev go/go1.20.4 git-commit/8d67d0c1a8 kernel/5.15.49-linuxkit-pr os/linux arch/arm64 containerd-client/1.6.21+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/24.0.2 \\(linux\\))"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d099e47e00)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 11:41:10 +02:00
Sebastiaan van Stijn
8018ee4689
dockerversion: DockerUserAgent(): allow custom versions to be passed
Allow additional metadata to be passed as part of the generated User-Agent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a6da1480b5)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 11:41:09 +02:00
Sebastiaan van Stijn
ed376a603f
dockerversion: remove insertUpstreamUserAgent()
It was not really "inserting" anything, just formatting and appending.
Simplify this by changing this in to a `getUpstreamUserAgent()` function
which returns the upstream User-Agent (if any) into a `UpstreamClient()`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 9a1f2e6d7c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 11:41:09 +02:00
Sebastiaan van Stijn
1d45ea52f4
dockerversion: simplify escapeStr()
Use a const for the characters to escape, instead of implementing
this as a generic escaping function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit ff40d2d787)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 11:41:09 +02:00
Sebastiaan van Stijn
a27b0381a6
dockerversion: add a basic unit-test
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit eb9a5392bc)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-02 11:41:09 +02:00
Djordje Lukic
1fc19772e0
Make sure the image is unpacked for the current snapshotter
Switching snapshotter implementations would result in an error when
preparing a snapshot, check that the image is indeed unpacked for the
current snapshot before trying to prepare a snapshot.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
(cherry picked from commit ed32f5e241)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 22:50:53 +02:00
Brian Goff
9bdb6adf92
Merge pull request #45673 from thaJeztah/24.0_backport_consistent_alias
[24.0 backport] fixing consistent aliases for OCI spec imports
2023-06-01 12:34:00 -07:00
Sebastiaan van Stijn
7dbab75fec
Merge pull request #45674 from thaJeztah/24.0_backport_dockerfile_copy_link
[24.0 backport] Dockerfile: use COPY --link to copy artifacts from build-stages
2023-06-01 18:37:14 +02:00
Sebastiaan van Stijn
e7b1501832
Merge pull request #45671 from thaJeztah/24.0_backport_c8d_useragent
[24.0 backport] containerd: set user-agent when pushing/pulling images
2023-06-01 18:36:46 +02:00
Sebastiaan van Stijn
4217d9ea0a
Dockerfile: use COPY --link to copy artifacts from build-stages
Build-cache for the build-stages themselves are already invalidated if the
base-images they're using is updated, and the COPY operations don't depend
on previous steps (as there's no overlap between artifacts copied).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 637ca59375)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 17:29:46 +02:00
Jeyanthinath Muthuram
4c6b8e737f
added alias validation
Signed-off-by: Jeyanthinath Muthuram <jeyanthinath10@gmail.com>
(cherry picked from commit 71d7908656)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 17:23:07 +02:00
Jeyanthinath Muthuram
e370f224ae
fixing consistent aliases for OCI spec imports
Signed-off-by: Jeyanthinath Muthuram <jeyanthinath10@gmail.com>
(cherry picked from commit 307b09e7eb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 17:22:49 +02:00
Sebastiaan van Stijn
ac1a867282
vendor: github.com/mistifyio/go-zfs/v3 v3.0.1
Switching to the v3 version, which was renamed to be compatible with
go modules.

Full diff: https://github.com/mistifyio/go-zfs/compare/f784269be439...v3.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 86108812b8)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 17:14:33 +02:00
Sebastiaan van Stijn
2949fee1d3
containerd: set user-agent when pushing/pulling images
Before this, the client would report itself as containerd, and the containerd
version from the containerd go module:

    time="2023-06-01T09:43:21.907359755Z" level=info msg="listening on [::]:5000" go.version=go1.19.9 instance.id=67b89d83-eac0-4f85-b36b-b1b18e80bde1 service=registry version=2.8.2
    ...
    172.18.0.1 - - [01/Jun/2023:09:43:33 +0000] "HEAD /v2/multifoo/blobs/sha256:cb269d7c0c1ca22fb5a70342c3ed2196c57a825f94b3f0e5ce3aa8c55baee829 HTTP/1.1" 404 157 "" "containerd/1.6.21+unknown"

With this patch, the user-agent has the docker daemon information;

    time="2023-06-01T11:27:07.959822887Z" level=info msg="listening on [::]:5000" go.version=go1.19.9 instance.id=53590f34-096a-4fd1-9c58-d3b8eb7e5092 service=registry version=2.8.2
    ...
    172.18.0.1 - - [01/Jun/2023:11:27:20 +0000] "HEAD /v2/multifoo/blobs/sha256:c7ec7661263e5e597156f2281d97b160b91af56fa1fd2cc045061c7adac4babd HTTP/1.1" 404 157 "" "docker/dev go/go1.20.4 git-commit/8d67d0c1a8 kernel/5.15.49-linuxkit-pr os/linux arch/arm64 UpstreamClient(Docker-Client/24.0.2 \\(linux\\))"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 66137ae429)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-06-01 17:10:08 +02:00
Bjorn Neergaard
7861aa7e80
Merge pull request #45659 from corhere/backport-24.0/libn/setup-resolver-with-verbose-iptables
[24.0 backport] libnetwork: fix resolver restore w/ chatty 'iptables -C'
2023-05-30 15:31:12 -06:00