Commit Graph

4568 Commits

Author SHA1 Message Date
Matt Heon
d420fbfde3 Add migration code for BoltDB to SQLite
This is gated behind a new option in `podman system migrate`,
`--migrate-db`, or by a system restart being performed.

BoltDB support was removed in Podman 6, so we are certain that,
when we start Podman, a SQLite state is in use. However, if we
also detect a valid BoltDB state, we will attempt a migration.

Migration is performed by retrieving all volumes, pods, and
containers (in that order, to ensure there are no dependency
conflicts) from the Bolt database, when adding them to the SQLite
database. If there is a conflict - IE, a container exists in both
SQLite and Bolt - we skip migration for that object. The old DB
is then renamed so we do not try to migrate it again.

Our ability to test complex migration scenarios is limited, but
this should handle simple migrations easily.

This is a heavily adapted version of #27660 rebuilt to work with
Podman 6.0. Substantial changes were required to throw errors
when a BoltDB database is detected and no migration is being
performed. Firstly, for automatic on-reboot migrations, we need
to have a deferred error returned by getDBState (very early in
runtime initialization) that is only acted on much later (once we
know for certain a state refresh is/is not being performed).
The `system migrate --migrate-db` command was much more
problematic. Conceptually, it's not terrible - add a flag to the
runtime to suppress errors, set that flag only when calling the
`system migrate` command with `--migrate-db` - but it unveiled a
serious problem with how we do runtime init (special flags to the
runtime were being ignored because the image runtime set the
Libpod runtime first and had none of the proper handling) which
took a genuinely annoying amount of time to identify and fix.

This cannot be tested automatically, as the ability to create Bolt
databases has been entirely removed with Podman 6.

This also includes 9b810aed3a from
the v5.8 branch by Luap99, which I have had to squash into this
commit to satisfy the build-each-commit check. It was just a
simplification of the SQLite path check.

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2026-05-08 14:07:17 -04:00
Matthew Heon
abf885dfcc Re-add a minimal version of BoltDB for migrations
If we're going to maintain migration capability for the full
lifespan of 6 - and I think we're going to have to - the only
sane options are a separate binary that exclusively performs
migrations, or re-adding BoltDB code - in a very minimal way - to
allow us to perform migrations within the standard 6 binary.
After attempting the separate binary approach, results are not
promising - it's impossible to strip enough out to make a truly
small binary that still does what we need to perform a migration.
That leaves re-adding BoltDB code.

This adds a minimal version of the BoltDB code that no longer
claims to be a valid State (freeing us from the requirement of
continued maintenance - we should never touch these bits again
until they get removed in 7) which has just enough to get every
container, pod, and volume in the DB, so we can migrate them to
SQLite.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2026-05-05 15:42:04 -04:00
Clayton Craft
c7ed32c266 libpod: limit splitting of cgroup fields
Apparently paths can have colons in them, and this completely breaks
parsing:

Error: could not find any cgroup in "/proc/6080/cgroup"
$ cat /proc/6080/cgroup
0::/user.slice/user-10000.slice/user@10000.service/app.slice/app-dbus\x2d:1.2\x2dorg.gnome.Console.slice/3809f153fce7324de5298d0d9b2782bb76f75f4603c2085acce13f71348c1fb6

This limits the split to 3 fields, so that colons in the path don't
cause problems.

Signed-off-by: Clayton Craft <clayton@craftyguy.net>
2026-04-30 09:52:08 -07:00
Matt Heon
3bd7bbc0dc Merge pull request #28413 from simonbrauner/issue-26786
Use AND to combine different volume filter keys
2026-04-28 13:59:42 -04:00
Paul Holzinger
241e59b9af Merge pull request #28494 from agp8x/fix/keep-pod-hostname
keep pod hostname when a container is stopped
2026-04-28 17:52:39 +02:00
Lokesh Mandvekar
9b253ab347 Update stale comments referencing slirp4netns
Replace remaining references to Slirp/slirp4netns in code comments
with Pasta or remove them where the reference is no longer relevant.

Signed-off-by: Lokesh Mandvekar <lsm5@linux.com>
2026-04-27 10:22:26 -04:00
Clemens Klug
24130e2a0c keep pod hostname when a container is stopped
When a container in a pod is stopped, its container name is removed from /etc/hosts. etchosts.Remove() filters for any entry matching the container name or the pod hostname. A pod with additional host entries like --add-host FQDN;pod-hostname:127.0.0.1 is affected by this deletion, too.

Only the container name needs to be removed when a container is stopped.

Signed-off-by: Clemens Klug <git@agp8x.org>
2026-04-24 10:20:43 +00:00
Paul Holzinger
56a24d5183 fix container inspect output to not escape html chars
The default std json behavior is to escape &, < and >. Because we print
to the terminal we do not want escapes and rather the real chars.

That is what PrintGenericJSON() does but because we have custom
MarshalJSON() overwrite on the type which called json.Marshal() this
option was not carried into that. The inner type must not escape it.

This is not a problem in the other direction because the outer
json.Marshal call will still escape the chars returned from the inner
MarshalJSON() result if needed.

Fixes: #28560

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-04-23 20:12:14 +02:00
Paul Holzinger
62ac844a6d Merge pull request #28567 from Honny1/small-fix
Cleanup from deterministic network order PR #28275
2026-04-23 06:03:47 +02:00
Brent Baude
2cc3be7332 RUN-4539: Change podman module paths
The podman module paths are moving from github.com/containers/podman to
go.podman.io/podman.  This will help with future mobility.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-22 14:02:25 -05:00
Jan Rodák
6df67e0e19 Fix LegacyNetworks comments and add deprecation notice
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-04-22 19:03:32 +02:00
Matt Heon
f5629c9ce0 Merge pull request #28558 from osullivandonal/sqlite-remove-volume-config-verify-deletion
SQLite verify that a Volume config was actually deleted
2026-04-22 11:45:09 -04:00
Jan Rodák
103d059904 Reuse found network in NetworkDisconnect
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-04-22 17:42:55 +02:00
Donal O'Sullivan
2adfe1d4d9 Verify that a Volume config was actually deleted
Check the result from the volume config deletion
to verify rows were actually affected. If no
rows were deleted, return ErrNoSuchVolume.

Signed-off-by: Donal O'Sullivan <osullivanpatrickdonal@gmail.com>
2026-04-22 13:43:37 +01:00
Brent Baude
2e6f29a2df RUN-4538: Fix buildah vendoring
This PR reflects the upstream change of moving the buildah module from
github.com/containers/buildah to go.podman.io/buildah.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2026-04-21 14:27:58 -05:00
Jan Kaluza
54d61c2f02 trust: switch policy.json lookup to configfile
Use shared configfile instead of custom policy.json path handling.
This updates ocipull to rely on signature.DefaultPolicy(), removes
explicit SignaturePolicyPath, and replaces trust's custom default-policy
path logic with common configfile code.

Replace hidden `--policypath` with --signature-policy` and require
it for `trust set` command instead of path resolution based on
configfile.

For `trust get`, the `--signature-policy` is optional.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2026-04-20 15:11:22 +02:00
Matthew Heon
5e94c95ad0 Move to deterministic network setup order
This was implemented by containers/netavark #1369; this commit
completes the process by wiring it into Podman. We now respect
the CLI order for configured networks - if a user passes
`--net net1,net2` we guarantee that net1 will be configured
before net2.

For containers created before this patch, we don't retain enough
information to configure networks in CLI order, so we use
alphabetical order instead to still guarantee consistency.

No breaking API changes have been made, but we do add a new
field to supplement the existing map to (optionally) provide
ordering information. The Podman CLI will always pass this.
Existing applications that do not will, again, receive]
deterministic ordering based on an alphabetical sort of network
names.

This requires the latest version of Netavark to work properly.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2026-04-17 10:00:32 -04:00
Paul Holzinger
e4776a2dc6 Merge pull request #28498 from Honny1/hc-transient-store
Fix healthcheck failing silently with `--transient-store`
2026-04-15 19:13:19 +02:00
Jan Rodák
9598b30ac2 Fix healthcheck failing silently with --transient-store
The systemd timer created for health checks did not pass global
podman flags to the subprocess, causing it to use default storage
settings instead of matching the parent process. This is most
visible with --transient-store, where the healthcheck looks up
the container in the default store instead of the volatile one.

Extract GlobalPodmanArgs() from CreateExitCommandArgs so both the
exit command and healthcheck timer share the same set of global
flags (--root, --runroot, --transient-store, --storage-driver, etc.).

Fixes: https://github.com/containers/podman/issues/28483

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-04-14 14:13:20 +02:00
Lokesh Mandvekar
9ff3f4cb1e Clean up outdated slirp4netns references in comments
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-04-13 09:05:09 -04:00
Lokesh Mandvekar
c23da53456 Remove unused slirp4netns imports and Slirp4NetNS field
Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-04-13 09:04:41 -04:00
Lokesh Mandvekar
cefb944647 Remove slirp4netns setup functions (preserve RLK)
Remove all slirp4netns-specific setup and helper functions while
preserving the RootlessRLK port mapping functions that are still
used by pasta and bridge networking.

Rename networking_slirp4netns.go to networking_rootlessport.go.
Convert the slirp4netns compose test to use pasta instead.
Remove rootlessSlirpSyncR/W fields from container struct and
getSlirp4netnsIP stub from FreeBSD networking.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-04-13 09:04:41 -04:00
Lokesh Mandvekar
e81328e2a2 Remove Slirp network mode constant and error on usage
Using --network=slirp4netns now returns a hard error directing
users to pasta and `podman system migrate`.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-04-13 08:22:36 -04:00
Lokesh Mandvekar
a172d25f86 Add slirp4netns to pasta migration
Add slirp4netns to pasta migration in `podman system migrate`. When
run, it changes the NetMode from slirp4netns to pasta and removes
any slirp4netns network options. Warns about options that cannot be
mapped to pasta (e.g. cidr, allow_host_loopback). The config is
persisted via RewriteContainerConfig.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-04-13 08:22:36 -04:00
Paul Holzinger
80df8f2f2e Merge pull request #24126 from inknos/issue-23824
Docker compat: Return null when swappiness is unset instead of -1
2026-04-10 19:04:21 +02:00
Paul Holzinger
25aee24cbd use chrootarchive over plain archive package
Just as additional hardening.

Note chrootarchive does not work on macos/windows, in that case it still
falls back to the regular pkg/archive.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-04-08 19:58:07 +02:00
Nicola Sella
8dd7ac5756 Fix: set Swappiness when no mem limits
This hard codes -1 on inspect for Docker's API to return `null` and be compatible

Fixes: https://github.com/containers/podman/issues/23824

Signed-off-by: Nicola Sella <nsella@redhat.com>
2026-04-08 15:10:11 +02:00
Šimon Brauner
98abcdcb19 Use AND to combine different volume filter keys
Fixes: https://github.com/containers/podman/issues/26786

Signed-off-by: Šimon Brauner <sbrauner@redhat.com>
2026-04-07 09:23:22 +02:00
Paul Holzinger
d20933df02 add missing O_CLOEXEC to open calls
The go std os package to will always make sure to use O_CLOEXEC, however
in cases where we directly call unix.Open() we need to pass that flag
explicitly.

I looked at this as there was a report of a leaked fd on the pasta list,
though I am not sure this will address it.

But anyway doing this should be rather safe and avoid leaks into other
processes.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-04-02 15:06:37 +02:00
Jan Rodák
b2f720537f Merge pull request #28365 from crawfordxx/fix-race-condition-in-hijackWriteErrorAndClose
libpod: fix data race on deferredErr in attachExecHTTP
2026-03-31 11:44:26 +02:00
crawfordxx
497185c14b libpod: fix data race on deferredErr in attachExecHTTP
ExecContainerHTTP returns attachChan to its caller before attachExecHTTP
finishes. The caller's deferred close(holdConnOpen) can therefore fire
while attachExecHTTP is still running (including its own deferred
cleanups), which races with the goroutine inside attachExecHTTP that
reads deferredErr after <-holdConnOpen unblocks.

Fix this by introducing an errCh channel: deferred functions write
deferredErr into it, and the goroutine reads from it after
<-holdConnOpen unblocks, ensuring the read happens-after all writes to
the named return value.

Fixes: #28277
Signed-off-by: crawfordxx <crawfordxx@users.noreply.github.com>
2026-03-29 12:03:59 +08:00
SIMVIA-lucas-sovre
d2ff809c66 Fixes: #27620 replace dots by hyphens in kubectl volume names generation
Signed-off-by: SIMVIA-lucas-sovre <lucas.sovre@simvia.tech>
2026-03-26 12:02:31 +01:00
Danish Prakash
9565002257 feat: add support for changing default host IPs via containers.conf
Add support for `default_host_ips` in containers.conf to set default
host IP(s) if no IP is set when forwarding ports. Multiple IPs can be
configured, and passing explicit IP with -p will always override
the configured defaults.

Signed-off-by: Danish Prakash <contact@danishpraka.sh>
2026-03-20 13:54:48 +05:30
Paul Holzinger
0147339e8e Merge pull request #28202 from lsm5/podman6-no-cni-vendor
Podman6: Vendor update w/o CNI + additional cleanups
2026-03-19 21:44:01 +01:00
Paul Holzinger
d2e7e8192e Merge pull request #28235 from Honny1/volume-prune-docker
`podman volume prune`: match Docker defaults, add `--all` flag
2026-03-19 17:53:18 +01:00
Lokesh Mandvekar
61cb417c26 Remove CNI references from comments
Update comments that reference CNI as a network backend since it
has been removed.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-03-19 20:26:21 +05:30
Lokesh Mandvekar
8d1f636e40 vendor update without CNI in buildah and container-libs
rootlessport: clarify RootlessCNI comment

Update the comment for the RootlessCNI conditional to clarify that
the flag is for rootless bridge networking, not CNI specifically.
The bool is set when netStatus != nil in slirp4netns and will be
removed when slirp4netns and rootlessport are fully dropped.

Signed-off-by: Lokesh Mandvekar <lsm5@redhat.com>
2026-03-19 20:26:21 +05:30
Tom Sweeney
bb9d188d4a Merge pull request #28236 from Honny1/fix-unless-stopped
Fix `unless-stopped` containers not restarting after `podman-restart-service` stop them
2026-03-19 10:45:28 -04:00
Jan Rodák
d887a8146a Fix creating unnamed volumes as anonymous
Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-03-19 13:40:47 +01:00
Doug Rabson
9a10cefd18 libpod: Don't dereference ctrSpec.Linux if it is nil
This prevents a nil pointer crash when running network=host containers
on a FreeBSD host using podman-remote.

Fixes: #28289
Signed-off-by: Doug Rabson <dfr@rabson.org>
2026-03-18 13:50:05 +00:00
Jan Rodák
7326b862e3 Fix unless-stopped containers not restarting after podman-restart.service stop them
When `podman-restart.service` stops containers, it marks them as "stopped by
user" which breaks the `unless-stopped` restart policy. Add hidden
`--not-stopped-by-user` flag to prevent this, allowing `unless-stopped`
containers to restart on next boot.

Fixes: https://github.com/containers/podman/issues/28152
Fixes: https://issues.redhat.com/browse/RUN-4357

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-03-16 13:51:17 +01:00
Paul Holzinger
14dd313d41 Merge pull request #27766 from Banana-Cultist/podman-events-oom
Improve OOMKilled Visibility
2026-03-12 19:23:02 +01:00
Paul Holzinger
1f3c344312 run modernize -fix ./...
modernize seems to be smarter now so it found some more things that are
not even go 1.25 related.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2026-03-12 17:22:01 +01:00
Ashley Cui
54634fb559 Merge pull request #28233 from Honny1/improve-relabel-err
Improve relabel EPERM error for rootless
2026-03-12 08:07:45 -04:00
Bruce Fan
ffeb0d103b Improve OOMKilled visibility in podman events and in podman inspect docs
Signed-off-by: Bruce Fan <brucexfan@gmail.com>
2026-03-11 10:15:56 -05:00
Jan Rodák
35f9d61fcb Improve relabel EPERM error for rootless
Fixes: https://github.com/containers/podman/issues/27184

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-03-10 14:17:26 +01:00
Jan Kaluza
8c4edb6121 libpod: include names-generator.go
In the moby/moby, the namesgenerator is internal. We still want to
depend on it, so this commit copies it from moby/moby to our code-base.

The good thing is the file is frozen upstream, so no more changes are
going to appear in it.

Fixes: #27536.

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2026-03-09 16:08:43 +01:00
Paul Holzinger
5adac65c0a Merge pull request #28208 from mtrmac/tls-behavior-basics
Add --tls-details for (pull, push, run, login, logout)
2026-03-06 16:33:38 +01:00
Povilas Kanapickas
636eb1a401 libpod: Implement --log-opt label=LABEL=Value
This allows things like compose project names to be associated with log
messages and later used in log processing and analysis.

Signed-off-by: Povilas Kanapickas <povilas@radix.lt>
2026-03-06 10:59:31 +02:00
Miloslav Trmač
13e1d5af4b PARTIALLY TESTED: Add --tls-details, use it to affect libimage and the like
For remote operation, start the remote service with --tls-details:
using --tls-details on the client side will only affect client's
connection.

This should eventually include many more tests - track down all current
uses of libpod.Runtime.{SystemContext,imageContext,LibimageRuntime}.
That will come later

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2026-03-05 23:13:17 +01:00