summaryrefslogtreecommitdiff
path: root/cmd
Commit message (Collapse)AuthorAgeFilesLines
* daemon: remove handling for deprecated "oom-score-adjust", and produce errorSebastiaan van Stijn2023-05-064-23/+2
| | | | | | | | | | | | | | | | | | | | | | | | | This option was deprecated in 5a922dc162bbe0a03450165da4e6aceca55073d4, which is part of the v24.0.0 release, so we can remove it from master. This patch; - adds a check to ValidatePlatformConfig, and produces a fatal error if oom-score-adjust is set - removes the deprecated libcontainerd/supervisor.WithOOMScore - removes the warning from docker info With this patch: dockerd --oom-score-adjust=-500 --validate Flag --oom-score-adjust has been deprecated, and will be removed in the next release. unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed. And when using `daemon.json`: dockerd --validate unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" options have been removed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #45314 from corhere/graceful-shutdownSebastiaan van Stijn2023-04-285-81/+139
|\ | | | | cmd/dockerd: gracefully shut down the API server
| * cmd/dockerd: gracefully shut down the API serverCory Snider2023-04-262-42/+105
| | | | | | | | | | | | | | | | | | | | | | As of Go 1.8, "net/http".Server provides facilities to close all listeners, making the same facilities in server.Server redundant. http.Server also improves upon server.Server by additionally providing a facility to also wait for outstanding requests to complete after closing all listeners. Leverage those facilities to give in-flight requests up to five seconds to finish up after all containers have been shut down. Signed-off-by: Cory Snider <csnider@mirantis.com>
| * cmd/dockerd/trap: log to logrus directlyCory Snider2023-04-263-9/+7
| | | | | | | | | | | | | | | | | | | | Logging through a dependency-injected interface value was a vestige of when Trap was in pkg/signal to avoid importing logrus in a reusable package: cc4da8112814cdbb00dbf23370f9ed764383de1f. Now that Trap lives under cmd/dockerd, nobody will be importing this so we no longer need to worry about minimizing the package's dependencies. Signed-off-by: Cory Snider <csnider@mirantis.com>
| * cmd/dockerd/trap: don't force exit after cleanupCory Snider2023-04-261-27/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Always calling os.Exit() on clean shutdown may not always be desirable as deferred functions are not run. Let the cleanup callback decide whether or not to call os.Exit() itself. Allow the process to exit the normal way, by returning from func main(). Simplify the trap.Trap implementation. The signal notifications are buffered in a channel so there is little need to spawn a new goroutine for each received signal. With all signals being handled in the same goroutine, there are no longer any concurrency concerns around the interrupt counter. Signed-off-by: Cory Snider <csnider@mirantis.com>
| * cmd/dockerd: ignore SIGPIPE using signal.IgnoreCory Snider2023-04-252-9/+9
| | | | | | | | | | | | | | The fix to ignore SIGPIPE signals was originally added in the Go 1.4 era. signal.Ignore was first added in Go 1.5. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | Use the image service instead of the reference store for taggingDjordje Lukic2023-04-261-0/+1
|/ | | | | | | | The image store sends events when a new image is created/tagged, using it instead of the reference store makes sure we send the "tag" event when a new image is built using buildx. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
* Merge pull request #45315 from thaJeztah/deprecate_oom_score_adjustSebastiaan van Stijn2023-04-142-3/+6
|\ | | | | daemon: deprecate --oom-score-adjust for the daemon
| * daemon: deprecate --oom-score-adjust for the daemonSebastiaan van Stijn2023-04-132-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The `oom-score-adjust` option was added in a894aec8d81de5484152a76d76b80809df9edd71, to prevent the daemon from being OOM-killed before other processes. This option was mostly added as a "convenience", as running the daemon as a systemd unit was not yet common. Having the daemon set its own limits is not best-practice, and something better handled by the process-manager starting the daemon. Commit cf7a5be0f2ee8bb4a3f7961682e13b89bc625299 fixed this option to allow disabling it, and 2b8e68ef06ca3daf2b0e17e51ba72999773b6270 removed the default score adjust. This patch deprecates the option altogether, recommending users to set these limits through the process manager used, such as the "OOMScoreAdjust" option in systemd units. With this patch: dockerd --oom-score-adjust=-500 --validate Flag --oom-score-adjust has been deprecated, and will be removed in the next release. configuration OK echo '{"oom-score-adjust":-500}' > /etc/docker/daemon.json dockerd INFO[2023-04-12T21:34:51.133389627Z] Starting up INFO[2023-04-12T21:34:51.135607544Z] containerd not running, starting managed containerd WARN[2023-04-12T21:34:51.135629086Z] DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" option will be removed in the next release. docker info Client: Context: default Debug Mode: false ... DEPRECATED: The "oom-score-adjust" config parameter and the dockerd "--oom-score-adjust" option will be removed in the next release Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | daemon: touch-up flag description for --seccomp-profileSebastiaan van Stijn2023-04-131-1/+1
|/ | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* split GetRepository from ImageServiceSebastiaan van Stijn2023-04-091-2/+2
| | | | | | | | | | | | | | | | | | | | | The GetRepository method interacts directly with the registry, and does not depend on the snapshotter, but is used for two purposes; For the GET /distribution/{name:.*}/json route; https://github.com/moby/moby/blob/dd3b71d17c614f837c4bba18baed9fa2cb31f1a4/api/server/router/distribution/backend.go#L11-L15 And to satisfy the "executor.ImageBackend" interface as used by Swarm; https://github.com/moby/moby/blob/58c027ac8ba19a3fa339c65274ea6704ccbec977/daemon/cluster/executor/backend.go#L77 This patch removes the method from the ImageService interface, and instead implements it through an composite struct that satisfies both interfaces, and an ImageBackend() method is added to the daemon. Signed-off-by: Sebastiaan van Stijn <github@gone.nl> remove GetRepository from ImageService Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Silence GRPC logs unless our log level is debugBrian Goff2023-03-212-0/+18
| | | | | | | | | | | | | | | GRPC is logging a *lot* of garbage at info level. This configures the GRPC logger such that it is only giving us logs when at debug level and also adds a log field indicating where the logs are coming from. containerd is still currently spewing these same log messages and needs a separate update. Without this change `docker build` is extremely noisy in the daemon logs. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* Move filtered registry search out of image serviceCory Snider2023-03-101-0/+1
| | | | | | | | | | | | | | | | | | | | | | | SearchRegistryForImages does not make sense as part of the image service interface. The implementation just wraps the search API of the registry service to filter the results client-side. It has nothing to do with local image storage, and the implementation of search does not need to change when changing which backend (graph driver vs. containerd snapshotter) is used for local image storage. Filtering of the search results is an implementation detail: the consumer of the results does not care which actor does the filtering so long as the results are filtered as requested. Move filtering into the exported API of the registry service to hide the implementation details. Only one thing---the registry service implementation---would need to change in order to support server-side filtering of search results if Docker Hub or other registry servers were to add support for it to their APIs. Use a fake registry server in the search unit tests to avoid having to mock out the registry API client. Signed-off-by: Cory Snider <csnider@mirantis.com>
* Fix listener parsering regression when no addr setBrian Goff2023-03-093-1/+107
| | | | | | | | | | | | | | | | | | 5008409b5cebe36690f653b71f171cf4e1ce114c introduced the usage of `strings.Cut` to help parse listener addresses. Part of that also made it error out if no addr is specified after the protocol spec (e.g. `tcp://`). Before the change a proto spec without an address just used the default address for that proto. e.g. `tcp://` would be `tcp://127.0.0.1:2375`, `unix://` would be `unix:///var/run/docker.sock`. Critically, socket activation (`fd://`) never has an address. This change brings back the old behavior but keeps the usage of `strings.Cut`. Signed-off-by: Brian Goff <cpuguy83@gmail.com>
* vendor: github.com/containerd/cgroups/v3 v3.0.1Akihiro Suda2023-03-081-1/+1
| | | | Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
* c8d: Make build and buildx workDjordje Lukic2023-03-071-25/+31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Only use the image exporter in build if we don't use containerd Without this "docker build" fails with: Error response from daemon: exporter "image" could not be found - let buildx know we support containerd snapshotter - Pass the current snapshotter to the buildkit worker If buildkit uses a different snapshotter we can't list the images any more because we can't find the snapshot. builder/builder-next: make ContainerdWorker a minimal wrapper Note that this makes "Worker" a public field, so technically one could overwrite it. builder-next: reenable runc executor Currently, without special CNI config the builder would only create host network containers that is a security issue. Using runc directly instead of shim is faster as well as builder doesn’t need anything from shim. The overhead of setting up network sandbox is much slower of course. builder/builder-next: simplify options handling Trying to simplify the logic; - Use an early return if multiple outputs are provided - Only construct the list of tags if we're using an image (or moby) exporter - Combine some logic for snapshotter and non-snapshotter handling Create a constant for the moby exporter Pass a context when creating a router The context has a 10 seconds timeout which should be more than enough to get the answer from containerd. Signed-off-by: Djordje Lukic <djordje.lukic@docker.com> Co-authored-by: Sebastiaan van Stijn <github@gone.nl> Co-authored-by: Tonis Tiigi <tonistiigi@gmail.com> Co-authored-by: Nicolas De Loof <nicolas.deloof@gmail.com> Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* Merge pull request #43197 from dajudge/default-bridge-mtuSebastiaan van Stijn2023-03-021-0/+1
|\ | | | | Introduce config option for default generic network options of newly created networks
| * Make default options for newly created networks configurableAlex Stockinger2023-03-011-0/+1
| | | | | | | | | | | | Signed-off-by: Alex Stockinger <alex@atomicjar.com> Co-authored-by: Sergei Egorov <bsideup@gmail.com> Co-authored-by: Cory Snider <corhere@gmail.com>
* | Merge pull request #45091 from corhere/remove-authz-middleware-from-configBrian Goff2023-03-021-13/+9
|\ \ | | | | | | daemon/config: remove AuthzMiddleware field
| * | daemon/config: remove AuthzMiddleware fieldCory Snider2023-03-011-13/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The authorization.Middleware contains a sync.Mutex field, making it non-copyable. Remove one of the barriers to allowing deep copies of config.Config values. Inject the middleware into Daemon as a constructor argument instead. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | | Merge pull request #45088 from corhere/make-apiserver-less-weirdCory Snider2023-03-011-9/+7
|\ \ \ | |/ / |/| | api/server: delete Wait method
| * | api/server: delete Wait methodCory Snider2023-03-011-9/+7
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It's surprising that the method to begin serving requests is named Wait. And it is unidiomatic: it is a synchronous call, but it sends its return value to the channel passed in as an argument instead of just returning the value. And ultimately it is just a trivial wrapper around serveAPI. Export the ServeAPI method instead so callers can decide how to call and synchronize around it. Call ServeAPI synchronously on the main goroutine in cmd/dockerd. The goroutine and channel which the Wait() API demanded are superfluous after all. The notifyReady() call was always concurrent and asynchronous with respect to serving the API (its implementation spawns a goroutine) so it makes no difference whether it is called before ServeAPI() or after `go ServeAPI()`. Signed-off-by: Cory Snider <csnider@mirantis.com>
* | api/server: drop unused Config structCory Snider2023-02-281-25/+17
|/ | | | | | | | | | | The Server.cfg field is never referenced by any code in package "./api/server". "./api/server".Config struct values are used by DaemonCli code, but only to pass around configuration copied out of the daemon config within the "./cmd/dockerd" package. Delete the "./api/server".Config struct definition and refactor the "./cmd/dockerd" package to pull configuration directly from cli.Config. Signed-off-by: Cory Snider <csnider@mirantis.com>
* cmd/dockerd: use default SIGQUIT behaviourCory Snider2023-01-102-12/+4
| | | | | | | | | | | | | | dockerd handles SIGQUIT by dumping all goroutine stacks to standard error and exiting. In contrast, the Go runtime's default SIGQUIT behaviour... dumps all goroutine stacks to standard error and exits. The default SIGQUIT behaviour is implemented directly in the runtime's signal handler, and so is both more robust to bugs in the Go runtime and does not perturb the state of the process to anywhere near same degree as dumping goroutine stacks from a user goroutine. The only notable difference from a user's perspective is that the process exits with status 2 instead of 128+SIGQUIT. Signed-off-by: Cory Snider <csnider@mirantis.com>
* rootless: move ./rootless to ./pkg/rootlessJan Garcia2023-01-093-3/+3
| | | | Signed-off-by: Jan Garcia <github-public@n-garcia.com>
* cmd/docker-proxy: add "-v / --version" flagSebastiaan van Stijn2022-12-271-4/+12
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #44649 from thaJeztah/config_cleanupSebastiaan van Stijn2022-12-273-10/+7
|\ | | | | daemon/config: rename CommonTLSOptions, and remove RootDeprecated field
| * daemon/config: remove deprecated RootDeprecated fieldSebastiaan van Stijn2022-12-151-3/+0
| | | | | | | | | | | | | | | | Since b58de39ca78a42e01f4e0d80c53ed11f8357be83, this option was now only used to produce a fatal error when starting the daemon. That change is in the 23.0 release, so we can remove it from the master branch. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * daemon/config: rename CommonTLSOptions to TLSOptionsSebastiaan van Stijn2022-12-152-7/+7
| | | | | | | | | | | | | | | | | | | | | | This type was added in 677a6b3506107468ed8c00331991afd9176fa0b9, and named "common", because at the time, the "docker" and "dockerd" (daemon) code were still in the same repository, and shared this type. Renaming it, now that's no longer the case. As there are no external consumers of this type, I'm not adding an alias. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | cmd/dockerd: use strings.Cut()Sebastiaan van Stijn2022-12-211-5/+3
|/ | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* cli: remove cli/config package, integrate into cmd/dockerdSebastiaan van Stijn2022-12-142-12/+50
| | | | | | | | | | | | The configDir (and "DOCKER_CONFIG" environment variable) is now only used for the default location for TLS certificates to secure the daemon API. It is a leftover from when the "docker" and "dockerd" CLI shared the same binary, allowing the DOCKER_CONFIG environment variable to set the location for certificates to be used by both. This patch merges it into cmd/dockerd, which is where it was used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* cli: move cobra customizations into cmd/dockerdSebastiaan van Stijn2022-12-144-3/+175
| | | | | | | | | The cli package is a leftover from when the "docker" and "dockerd" cli were both maintained in this repository; the only consumer of this is now the dockerd CLI, so we can move this code (it should not be imported by anyone). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* use ad-hoc libtrust keySebastiaan van Stijn2022-11-281-2/+0
| | | | | | | | This is only used for tests, and the key is not verified anymore, so instead of creating a key and storing it, we can just use an ad-hoc one. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* daemon/config: remove TrustKeyPath, and local utilitiesSebastiaan van Stijn2022-11-285-25/+1
| | | | | | | | | | | | | Turned out that the loadOrCreateTrustKey() utility was doing exactly the same as libtrust.LoadOrCreateTrustKey(), so making it a thin wrapped. I kept the tests to verify the behavior, but we could remove them as we only need this for our integration tests. The storage location for the generated key was changed (again as we only need this for some integration tests), so we can remove the TrustKeyPath from the config. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* cmd/dockerd: adjust error message for pidfile changesSebastiaan van Stijn2022-11-041-1/+1
| | | | Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/pidfile: Write(): don't automatically create parent directoriesSebastiaan van Stijn2022-11-041-0/+3
| | | | | | | | | | | | While this was convenient for our use, it's somewhat unexpected for a function that writes a file to also create all parent directories; even more because this function may be executed as root. This patch makes the package more "safe" to use as a generic package by removing this functionality, and leaving it up to the caller to create parent directories, if needed. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* pkg/pidfile: Write(): take pid as argumentSebastiaan van Stijn2022-11-041-1/+1
| | | | | | This allows it to be used for processes other than the daemon itself. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* cmd/dockerd: Rewrite shutdownDaemon to use context timeoutCory Snider2022-11-031-15/+12
| | | | Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* imageservice: Add context to various methodsNicolas De Loof2022-11-031-3/+3
| | | | | Co-authored-by: Paweł Gronowski <pawel.gronowski@docker.com> Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
* Fix the max-concurrent-downloads and max-concurrent-uploads configs ↵Luis Henrique Mulinari2022-10-261-2/+2
| | | | | | | | | documentation This fix tries to address issues raised in #44346. The max-concurrent-downloads and max-concurrent-uploads limits are applied for the whole engine and not for each pull/push command. Signed-off-by: Luis Henrique Mulinari <luis.mulinari@gmail.com>
* pkg/pidfile: remove PIDFile type, rename New() to Write()Sebastiaan van Stijn2022-10-151-3/+2
| | | | | | | | | This type felt really redundant; `pidfile.New()` takes the path of the file to create as an argument, so this is already known. The only thing the PIDFile type provided was a `Remove()` method, which was just calling `os.Remove()` on the path of the file. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #44287 from thaJeztah/use_SetRecoveryActionsTianon Gravi2022-10-141-29/+7
|\ | | | | cmd/dockerd: use x/sys Service.SetRecoveryActions(), and update restart delay
| * Change restart delay for Windows service to 15sSebastiaan van Stijn2022-10-121-2/+2
| | | | | | | | | | | | | | | | | | Previously we waited for 60 seconds after the service faults to restart it. However, there isn't much benefit to waiting this long. We expect 15 seconds to be a more reasonable delay. Co-Authored-by: Kevin Parsons <kevpar@microsoft.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| * cmd/dockerd: use golang.org/x/sys Service.SetRecoveryActions()Sebastiaan van Stijn2022-10-121-29/+7
| | | | | | | | | | | | This is the equivalent of the local implementation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | Merge pull request #44286 from thaJeztah/use_SetStdHandleTianon Gravi2022-10-141-11/+7
|\ \ | | | | | | cmd/dockerd: use golang.org/x/sys/windows.SetStdHandle()
| * | cmd/dockerd: use golang.org/x/sys/windows.SetStdHandle()Sebastiaan van Stijn2022-10-121-11/+7
| |/ | | | | | | | | | | | | golang.org/x/sys/windows now implements this, so we can use that instead of a local implementation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* | cmd/dockerd: replace deprecated windows.IsAnInteractiveSession()Sebastiaan van Stijn2022-10-111-5/+6
|/ | | | | | | | | | | | | | | | | | | | | The `IsAnInteractiveSession` was deprecated, and `IsWindowsService` is marked as the recommended replacement. For details, see https://github.com/golang/sys/commit/280f808b4a5303f80a30dd9dc62f9a042d992ad0 > CL 244958 includes isWindowsService function that determines if a > process is running as a service. The code of the function is based on > public .Net implementation. > > IsAnInteractiveSession function implements similar functionality, but > is based on an old Stackoverflow post., which is not as authoritative > as code written by Microsoft for their official product. > > This change copies CL 244958 isWindowsService function into svc package > and makes it public. The intention is that future users will prefer > IsWindowsService to IsAnInteractiveSession. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* cmd/dockerd: fix empty-lines (revive)Sebastiaan van Stijn2022-09-282-2/+0
| | | | | | | cmd/dockerd/trap/trap_linux_test.go:29:29: empty-lines: extra empty line at the end of a block (revive) cmd/dockerd/daemon.go:327:35: empty-lines: extra empty line at the start of a block (revive) Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* set ReadHeaderTimeout to address G112: Potential Slowloris Attack (gosec)Sebastiaan van Stijn2022-09-221-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | After discussing in the maintainers meeting, we concluded that Slowloris attacks are not a real risk other than potentially having some additional goroutines lingering around, so setting a long timeout to satisfy the linter, and to at least have "some" timeout. libnetwork/diagnostic/server.go:96:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) srv := &http.Server{ Addr: net.JoinHostPort(ip, strconv.Itoa(port)), Handler: s, } api/server/server.go:60:10: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec) srv: &http.Server{ Addr: addr, }, daemon/metrics_unix.go:34:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec) if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { ^ cmd/dockerd/metrics.go:27:13: G114: Use of net/http serve function that has no support for setting timeouts (gosec) if err := http.Serve(l, mux); err != nil && !strings.Contains(err.Error(), "use of closed network connection") { ^ Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
* Merge pull request #43971 from thaJeztah/daemon_fix_hosts_validation_step1c3Sebastiaan van Stijn2022-08-181-4/+5
|\ | | | | daemon: use initialized config struct in more tests