Skip to content

remove direct dependency on docker/docker#13706

Open
glours wants to merge 1 commit intomainfrom
bump-docker-moby-v29.3.1
Open

remove direct dependency on docker/docker#13706
glours wants to merge 1 commit intomainfrom
bump-docker-moby-v29.3.1

Conversation

@glours
Copy link
Copy Markdown
Contributor

@glours glours commented Apr 3, 2026

What I did

  • Copy pkg/pidfile from moby/moby/v2 into internal/pidfile as a temporary internal package, removing the direct dependency on github.com/docker/docker for pidfile functionality
  • github.com/docker/docker moves from a direct to an indirect dependency (still transitively required by docker/buildx)
  • The internal copy includes platform-specific process-alive checks (unix/windows) and is intended to be replaced once pidfile is published as a standalone module

The github.com/docker/docker Go module has been deprecated and no longer receives releases. The moby/moby repository now publishes three modules (client, api, and v2), with only client and api intended for external use. The v2 module (daemon internals) is not meant for external consumption.

Per discussion with moby maintainers, the recommended approach is to copy the pkg/pidfile code as a temporary internal package until it is extracted into its own module.

Related issue
N/A

(not mandatory) A picture of a cute animal, if possible in relation to what you did

@glours glours requested a review from a team as a code owner April 3, 2026 12:29
@glours glours requested review from Copilot and ndeloof and removed request for Copilot April 3, 2026 12:29
@glours glours self-assigned this Apr 3, 2026
"os"

"github.com/docker/docker/pkg/pidfile"
"github.com/moby/moby/v2/pkg/pidfile"
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think short-term it'd be better to just copy the files to an internal package; we can look at moving some of the remaining pkg/xxx packages to github.com/moby/sys as a separate module.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW security warnings are definitely false positives; the CVEs only impact the daemon

@glours glours force-pushed the bump-docker-moby-v29.3.1 branch from c705780 to 7725189 Compare April 3, 2026 14:14
Copilot AI review requested due to automatic review settings April 3, 2026 14:14
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

I'll have a look next week to see if we can move some of the remaining pkg/ packages 👍

@thaJeztah
Copy link
Copy Markdown
Member

PR description probably should be updated though 🤔 😂

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR migrates Compose away from direct github.com/docker/docker imports by switching to the split github.com/moby/moby/* modules and introducing an internal pidfile helper to replace the previously used Engine pidfile package.

Changes:

  • Replace docker/docker version and stdcopy imports with moby/moby equivalents.
  • Add internal/pidfile as a temporary in-repo replacement for the removed docker/docker/pkg/pidfile dependency.
  • Adjust go.mod to drop the direct github.com/docker/docker requirement (remaining as an indirect dependency).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/compose/model.go Switch version comparison helper import to moby module.
pkg/compose/logs_test.go Switch stdcopy import to moby module; add test-only stdio mux writer helper.
internal/pidfile/pidfile.go Add internal pidfile Read/Write implementation (temporary copy).
internal/pidfile/pidfile_unix.go Add non-Windows “alive” implementation.
internal/pidfile/pidfile_windows.go Add Windows “alive” implementation.
internal/locker/pidfile_unix.go Update pidfile import to new internal package.
internal/locker/pidfile_windows.go Update pidfile import to new internal package.
go.mod Move github.com/docker/docker from direct to indirect requirement.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +35 to +37
return c == uint32(windows.STATUS_PENDING)
}
return true
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alive() always returns true if OpenProcess and GetExitCodeProcess succeed, regardless of whether the process has actually exited (exit code != STILL_ACTIVE). Additionally, when GetExitCodeProcess returns an error, the function compares an untrusted/undefined exit-code value against STATUS_PENDING. This can cause stale pidfiles to be treated as “still running” indefinitely on Windows. Consider returning false on GetExitCodeProcess error, and otherwise checking the returned exit code (e.g., windows.STILL_ACTIVE / equivalent) before returning true.

Suggested change
return c == uint32(windows.STATUS_PENDING)
}
return true
return false
}
return c == windows.STILL_ACTIVE

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's leave that for the module we're moving; ISTR there were some reasons to do this, but would have to check history 😂

Comment on lines +34 to +41
switch runtime.GOOS {
case "darwin":
err := unix.Kill(pid, 0)
return err == nil || errors.Is(err, unix.EPERM)
default:
_, err := os.Stat("/proc/" + strconv.Itoa(pid))
return err == nil
}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On non-Windows platforms, alive() falls back to checking for /proc/ for all OSes except darwin. This is less reliable than using unix.Kill(pid, 0) (which also lets you treat EPERM as “alive”) and can be wrong on Linux configurations that restrict /proc visibility (e.g., hidepid) and on Unix variants without /proc. Consider using unix.Kill(pid, 0) for the default case as well, similar to the darwin branch.

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +23
// Package pidfile provides helper functions to create and remove PID files.
// A PID file is usually a file used to store the process ID of a running
// process.
//
// This is a temporary copy of github.com/moby/moby/v2/pkg/pidfile, and
// should be replaced once pidfile is available as a standalone module.
package pidfile
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Package comment says it provides helper functions to “create and remove PID files”, but this package currently only implements Read and Write (no remove/delete helper). Consider either adding a Remove helper (if intended) or adjusting the package comment to match the actual API surface.

Copilot uses AI. Check for mistakes.
Signed-off-by: Guillaume Lours <glours@users.noreply.github.com>
@glours glours force-pushed the bump-docker-moby-v29.3.1 branch from 7725189 to 17e6632 Compare April 3, 2026 15:01
@glours glours changed the title use new moby/moby modules instead of docker/docker dependency remove direct dependency to docker/docker Apr 3, 2026
@glours glours changed the title remove direct dependency to docker/docker remove direct dependency on docker/docker Apr 3, 2026
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

we can look at the CoPilot comments in the moby repository (and when we move the package); I'm not sure if they are all legit concerns (could be!); this PR is just adding a temporary fork, so same code as already used.

@glours glours enabled auto-merge (rebase) April 3, 2026 15:13
@glours glours disabled auto-merge April 3, 2026 15:13
@glours glours enabled auto-merge (rebase) April 3, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants