Skip to content

fix: return error when --env-file does not exist#6961

Open
mohithshuka wants to merge 7 commits intodocker:masterfrom
mohithshuka:fix/env-file-missing-warning
Open

fix: return error when --env-file does not exist#6961
mohithshuka wants to merge 7 commits intodocker:masterfrom
mohithshuka:fix/env-file-missing-warning

Conversation

@mohithshuka
Copy link
Copy Markdown

Fixes #6853

What changed

Added a file existence check before reading --env-file values.
Previously, Docker silently ignored a missing env file. Now it returns
a clear error message.

How to reproduce

Before this fix

No error — command runs silently ignoring the missing file.

After this fix

mohithshuka and others added 7 commits April 9, 2026 17:45
Fixes #24643

--kernel-memory was deprecated in v20.10 and removed in v23.0.
Add deprecation callouts to both the options table and the
Kernel memory constraints section of the run reference page.
The --filter flag for 'docker volume prune' previously only showed
'label=<label>' as an example, not mentioning the negation form
'label!=<label>', even though it is valid and supported by the daemon.

Fixes docker#6918

Signed-off-by: mohithshuka <153504854+mohithshuka@users.noreply.github.com>
When a port is bound on both 0.0.0.0 and ::, hide the IPv6 entry
and show only the IPv4 entry to reduce noise in docker ps output.

Before: 0.0.0.0:8080->80/tcp, :::8080->80/tcp
After:  0.0.0.0:8080->80/tcp

Fixes docker#6869
The --archive (-a) flag description was misleading. Updated to clarify
that it preserves uid/gid from the source, and that it only takes
effect when copying files TO a container (not from).

Fixes docker#6870
Signed-off-by: mohithshuka <153504854+mohithshuka@users.noreply.github.com>
The local isDangling in list.go was missing the RepoDigests check,
causing images with a digest but no tag to be incorrectly filtered
from default 'docker images' output. Align with formatter.isDangling.

Fixes docker#6650
Copilot AI review requested due to automatic review settings April 30, 2026 16:17
@mohithshuka mohithshuka requested review from a team and thaJeztah as code owners April 30, 2026 16:17
Copy link
Copy Markdown

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 aims to improve Docker CLI UX and output consistency, primarily by changing how --env-file is handled when the file is missing, and includes several additional CLI/docs refinements.

Changes:

  • Add an explicit existence check for --env-file during container option parsing.
  • Suppress duplicate IPv6 wildcard port mappings in docker ps output when an IPv4 wildcard mapping already exists.
  • Update/help-text and documentation around --kernel-memory deprecation, docker cp -a behavior wording, volume prune filter examples, and dangling-image detection.

Reviewed changes

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

Show a summary per file
File Description
docs/reference/run.md Documents --kernel-memory as deprecated/removed and adds a deprecation callout in the kernel memory section.
docs/reference/commandline/cp.md Updates generated option text for docker cp -a.
docs/reference/commandline/container_cp.md Updates generated option text for docker container cp -a.
cli/command/volume/prune.go Expands --filter help text example to include label!=....
cli/command/image/list.go Adjusts dangling image detection to match formatter logic (tags + digests).
cli/command/formatter/container.go Avoids duplicate 0.0.0.0 + :: wildcard port mappings in formatted port output.
cli/command/container/opts.go Adds pre-check for --env-file existence before reading env vars.
cli/command/container/cp.go Updates docker cp -a flag description text.

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

Comment on lines +508 to +511
if _, err := os.Stat(ef); os.IsNotExist(err) {
return nil, fmt.Errorf("env file not found: %s", ef)
}
}
Comment on lines 506 to 513
// collect all the environment variables for the container
for _, ef := range copts.envFile.GetSlice() {
if _, err := os.Stat(ef); os.IsNotExist(err) {
return nil, fmt.Errorf("env file not found: %s", ef)
}
}
envVariables, err := opts.ReadKVEnvStrings(copts.envFile.GetSlice(), copts.env.GetSlice())
if err != nil {
Comment thread docs/reference/run.md
Comment on lines +505 to 516
> **Deprecated**
>
> The `--kernel-memory` option was deprecated in Docker v20.10 and removed in
> Docker v23.0. The Linux kernel deprecated `kmem.limit_in_bytes` in kernel
> v5.4, and OCI runtimes such as runc no longer support this option. Docker API
> v1.42 and later ignores this option when set. Do not use `--kernel-memory` in
> new configurations. For more details, see the
> [Deprecated features](https://docs.docker.com/engine/deprecated/) page.

Kernel memory is fundamentally different than user memory as kernel memory can't
be swapped out. The inability to swap makes it possible for the container to
block system services by consuming too much kernel memory. Kernel memory includes:
| Name | Type | Default | Description |
|:----------------------|:-------|:--------|:-------------------------------------------------------------------------------------------------------------|
| `-a`, `--archive` | `bool` | | Archive mode (copy all uid/gid information) |
| `-a`, `--archive` | `bool` | | Archive mode (preserve uid/gid from source when copying to container) |
Comment on lines +19 to 20
| `-a`, `--archive` | `bool` | | Archive mode (preserve uid/gid from source when copying to container) |
| `-L`, `--follow-link` | `bool` | | Always follow symbol link in SRC_PATH |
Comment on lines +508 to +511
if _, err := os.Stat(ef); os.IsNotExist(err) {
return nil, fmt.Errorf("env file not found: %s", ef)
}
}
Comment on lines +508 to +511
if _, err := os.Stat(ef); os.IsNotExist(err) {
return nil, fmt.Errorf("env file not found: %s", ef)
}
}
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.

No error for --env-file if the ./env file does not exist

2 participants