Commit graph

45416 commits

Author SHA1 Message Date
Bjorn Neergaard
e9275392c1
Merge pull request #44742 from akerouanton/fix-44688
Clear conntrack entries for published UDP ports
2023-01-05 10:04:29 -07:00
Nicolas De Loof
1616a09b61 add support for image inspect with containerd-integration
This is a squashed version of various PRs (or related code-changes)
to implement image inspect with the containerd-integration;

- add support for image inspect
- introduce GetImageOpts to manage image inspect data in backend
- GetImage to return image tags with details
- list images matching digest to discover all tags
- Add ExposedPorts and Volumes to the image returned
- Refactor resolving/getting images
- Return the image ID on inspect
- consider digest and ignore tag when both are set
- docker run --platform

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-05 16:20:41 +01:00
Paweł Gronowski
bbe6e9e8d1
hack/make: Don't add -buildmode=pie with -race
Make it possible to add `-race` to the BUILDFLAGS without making the
build fail with error:
"-buildmode=pie not supported when -race is enabled"

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-01-05 15:28:03 +01:00
CrazyMax
7e7b0622a6
hack: restore copy_binaries func
This function is still useful for the dev environment.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-05 13:21:28 +01:00
Albin Kerouanton
b37d34307d
Clear conntrack entries for published UDP ports
Conntrack entries are created for UDP flows even if there's nowhere to
route these packets (ie. no listening socket and no NAT rules to
apply). Moreover, iptables NAT rules are evaluated by netfilter only
when creating a new conntrack entry.

When Docker adds NAT rules, netfilter will ignore them for any packet
matching a pre-existing conntrack entry. In such case, when
dockerd runs with userland proxy enabled, packets got routed to it and
the main symptom will be bad source IP address (as shown by #44688).

If the publishing container is run through Docker Swarm or in
"standalone" Docker but with no userland proxy, affected packets will
be dropped (eg. routed to nowhere).

As such, Docker needs to flush all conntrack entries for published UDP
ports to make sure NAT rules are correctly applied to all packets.

- Fixes #44688
- Fixes #8795
- Fixes #16720
- Fixes #7540
- Fixes moby/libnetwork#2423
- and probably more.

As a precautionary measure, those conntrack entries are also flushed
when revoking external connectivity to avoid those entries to be reused
when a new sandbox is created (although the kernel should already
prevent such case).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-01-05 12:53:22 +01:00
Kirk Easterson
1fdfd45995 Updated outdated docker contributing guidelines link
Signed-off-by: Kirk Easterson <kirk.easterson@gmail.com>
2023-01-04 09:36:59 +01:00
Sebastiaan van Stijn
fcb52454ac
Merge pull request #44719 from vvoland/fix-volume-createdat
Fix volume CreatedAt being altered on initialization
2023-01-03 18:38:06 +01:00
Sebastiaan van Stijn
01fd23b625
Fix volume CreatedAt being altered on initialization
The CreatedAt date was determined from the volume's `_data`
directory (`/var/lib/docker/volumes/<volumename>/_data`).
However, when initializing a volume, this directory is updated,
causing the date to change.

Instead of using the `_data` directory, use its parent directory,
which is not updated afterwards, and should reflect the time that
the volume was created.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-01-03 16:57:04 +01:00
Sebastiaan van Stijn
b9fe30dad4
Merge pull request #44546 from crazy-max/dockerfile-cross
Dockerfile: use TARGETPLATFORM to build Docker
2023-01-02 17:56:21 +01:00
Sebastiaan van Stijn
f15d5a0661
Merge pull request #44426 from thaJeztah/deprecate_image_IDFromDigest
image: deprecate IDFromDigest(), and some minor fixes/cleanup
2023-01-02 12:38:29 +01:00
Sebastiaan van Stijn
d131147a5c
use errors.Is() to handle image store errors
The image store's used are an interface, so there's no guarantee
that implementations don't wrap the errors. Make sure to catch
such cases by using errors.Is.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-02 09:41:50 +01:00
CrazyMax
83280d44d0
docs: contributing docs update for cross comp
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:04 +01:00
CrazyMax
e8a82ed24d
Dockerfile: add "all" stage to build binaries and extra tools
We still need a stage that build binaries and extra tools as well for
docker-ce-packaging repo: ff110508ff/static/Makefile (L41-L57)

This could be removed if we create a package for each project
like it's done in docker-packaging repo: https://github.com/docker/packaging/tree/main/pkg

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:04 +01:00
CrazyMax
113e95ec02
ci: add extra steps to check artifacts
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:03 +01:00
CrazyMax
b565b496ba
Dockerfile: rename dev stages
Also remove DEV_IMAGE bake var that is not used

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:03 +01:00
CrazyMax
27ba1766e7
ci: use GITHUB_REF and GITHUB_SHA to set version and commit
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:03 +01:00
CrazyMax
0b3af098e1
bake: define additional vars
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:03 +01:00
CrazyMax
9bcf5bed05
bake: define DESTDIR
Keep the same output dir format in the bake definition
as the one used in make scripts.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:03 +01:00
CrazyMax
491467b0b9
hack: update buildmode pie condition
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:02 +01:00
CrazyMax
347a5f68da
hack: do not set buildmode pie for statically linked binary
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:02 +01:00
CrazyMax
e37985f590
hack: use PKG_CONFIG var when checking libdevmapper
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:02 +01:00
CrazyMax
84ea9ee0f9
IAmStatic not used anymore
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:02 +01:00
CrazyMax
04c90b8cf5
hack: remove containerutility script
this script is not used anymore. containerutility is
built in the Dockerfile.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:02 +01:00
CrazyMax
8086f40123
Dockerfile: use TARGETPLATFORM to build Docker
Better support for cross compilation so we can fully rely
on `--platform` flag of buildx for a seamless integration.

This removes unnecessary extra cross logic in the Dockerfile,
DOCKER_CROSSPLATFORMS and CROSS vars and some hack scripts as well.

Non-sandboxed build invocation is still supported and dev stages
in the Dockerfile have been updated accordingly.

Bake definition and GitHub Actions workflows have been updated
accordingly as well.

Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
2023-01-01 18:03:01 +01:00
Sebastiaan van Stijn
1de3966b84
image: store: rename vars that collided with types or shadowed vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-01 13:05:56 +01:00
Sebastiaan van Stijn
2910163df1
daemon/images: imageKey() accept string
To reduce some type-juggling :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-01 13:05:55 +01:00
Sebastiaan van Stijn
040b5bbc52
image: store.restore(): use more structured logs
This code below is run when restoring all images (which can be "many"),
constructing the "logrus.WithFields" is deliberately not "DRY", as the
logger is only used for error-cases, and we don't want to do allocations
if we don't need it. A "f" type-alias was added to make it ever so slightly
more DRY, but that's just for convenience :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-01 13:05:49 +01:00
Sebastiaan van Stijn
456ea1bb1d
image: deprecate IDFromDigest()
Having this function hides what it's doing, which is just to type-cast
to an image.ID (which is a digest). Using a cast is more transparent,
so deprecating this function in favor of a regular typecast.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-01-01 12:33:00 +01:00
Sebastiaan van Stijn
d109e429dd
Merge pull request #44723 from thaJeztah/devmapper_simplify_udev_error
daemon/graphdriver/devicemapper: simplify Udev log, and update link
2022-12-31 17:05:42 +01:00
Sebastiaan van Stijn
237c15888d
Merge pull request #44722 from thaJeztah/use_the_osusergo_luke
daemon/logger/gcplogs: remove ensureHomeIfIAmStatic workaround
2022-12-31 15:45:38 +01:00
Sebastiaan van Stijn
a5ebd28797
daemon/graphdriver/devicemapper: simplify Udev log, and update link
Simplify the error message so that we don't have to distinguish between static-
and non-static builds. Also update the link to the storage-driver section to
use a "/go/" redirect in the docs, as the anchor link was no longer correct.
Using a "/go/" redirect  makes sure the link remains functional if docs is  moving
around.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-31 14:36:57 +01:00
Sebastiaan van Stijn
155e39187c
daemon/logger/gcplogs: remove ensureHomeIfIAmStatic workaround
This function was added in b86e3bee5a to
work around an issue in os/user.Current(), which SEGFAULTS when compiling
statically with cgo enabled (see golang/go#13470).

We hit similar issues in other parts, and contributed a "osusergo" build-
tag in https://go-review.googlesource.com/c/go/+/330753. The "osusergo"
build tag must be set when compiling static binaries with cgo enabled.
If that build-tag is set, the cgo implementation for user.Current() won't
be used, and a pure-go implementation is used instead;
https://github.com/golang/go/blob/go1.19.4/src/os/user/cgo_lookup_unix.go#L5

With the above in place, we no longer need this workaround, and can remove
the ensureHomeIfIAmStatic() function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-31 13:59:06 +01:00
Cory Snider
8e69882c03
Merge pull request #44379 from thaJeztah/container_strings_cut
api/types/container: refactor to use strings.Cut, DRY, move tests and fix validation
2022-12-30 15:07:56 -05:00
Bjorn Neergaard
f5106148e3
Merge pull request #43060 from akerouanton/fix-42127
Check iptables options before looking for ip6tables binary
2022-12-29 17:13:36 -07:00
Sebastiaan van Stijn
eef2d20e23
Merge pull request #43285 from thaJeztah/cleanup_testutils
integration-cli: cleanup some of the test-utilities
2022-12-30 00:41:35 +01:00
Bjorn Neergaard
d8e3e6d606
Merge pull request #44705 from thaJeztah/inspect_literal
daemon: rename vars that collided, and use struct-literals
2022-12-29 16:08:22 -07:00
Bjorn Neergaard
865fdf4dcd
Merge pull request #44668 from masibw/44269-marshal-json-empty
api: can marshal and unmarshal when args.fields is empty
2022-12-29 15:39:50 -07:00
Akihiro Suda
2f9987c816
Merge pull request #44713 from thaJeztah/carry_44600_update_delve
Update delve version (carry 44600)
2022-12-30 07:23:58 +09:00
Sebastiaan van Stijn
5b908cfb5f
Merge pull request #44699 from thaJeztah/docker_proxy_version_flag
cmd/docker-proxy: add "-v / --version" flag
2022-12-29 21:01:18 +01:00
Yamazaki Masashi
5fed968b1d
api: can marshal and unmarshal when args.fields is empty
Signed-off-by: Yamazaki Masashi <masi19bw@gmail.com>
Signed-off-by: Bjorn Neergaard <bneergaard@mirantis.com>
2022-12-29 12:49:01 -07:00
Bjorn Neergaard
0e4efb15f5
Merge pull request #44707 from zhsj/btrfs-progs-6.1
daemon/graphdriver/btrfs: workaround field rename in btrfs-progs 6.1
2022-12-29 12:45:18 -07:00
oscar.chen
ad8804885c
Update delve version
Signed-off-by: oscar.chen <2972789494@qq.com>
2022-12-29 18:57:55 +01:00
Sebastiaan van Stijn
e7d75c8db7
api/types/container: fix validation for UTSMode, UsernsMode, PidMode
The IPCMode type was added in 497fc8876e, and from
that patch, the intent was to allow `host` (without `:`), `""` (empty, default)
or `container:<container ID>`, but the `Valid()` function seems to be too relaxed
and accepting both `:`, as well as `host:<anything>`. No unit-tests were added
in that patch, and integration-tests only tested for valid values.

Later on, `PidMode`, and `UTSMode` were added in 23feaaa240
and f2e5207fc9, both of which were implemented as
a straight copy of the `IPCMode` implementation, copying the same bug.

Finally, commit d4aec5f0a6 implemented unit-tests
for these types, but testing for the wrong behavior of the implementation.

This patch updates the validation to correctly invalidate `host[:<anything>]`
and empty (`:`) types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-29 18:49:27 +01:00
Sebastiaan van Stijn
018347f802
integration-cli: remove waitInspectWithArgs()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-29 18:26:12 +01:00
Sebastiaan van Stijn
61c434c030
integration-cli: remove inspectMountPointJSON()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-29 18:26:00 +01:00
Shengjing Zhu
ffbbe3d103 daemon/graphdriver/btrfs: workaround field rename in btrfs-progs 6.1
Closes: #44698

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
2022-12-29 03:47:12 +08:00
Sebastiaan van Stijn
0eb7b49a17
daemon: remove some intermediate vars, use struct-literals
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-28 11:26:44 +01:00
Sebastiaan van Stijn
288cf20f98
daemon: rename some vars that collided with imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-28 11:25:05 +01:00
Sebastiaan van Stijn
c5d4b6b311
restartmanager: remove RestartManager interface
It only had a single implementation, so we may as well remove the added
complexity of defining it as an interface.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-28 09:36:58 +01:00
Sebastiaan van Stijn
efb97da0da
restartmanager: add SetPolicy() to the RestartManager interface
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-12-28 09:36:58 +01:00