Commit Graph

1477 Commits

Author SHA1 Message Date
flouthoc 152849ebd2
libpod/build: add headers
Add `headers` for `/libpod/build`

Closes: https://github.com/containers/podman/issues/26440

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2025-07-08 06:51:32 -07:00
openshift-merge-bot[bot] 87d88c3b09
Merge pull request #26432 from stefwalter/dont-html-escape-json
api: Don't HTML escape application/json responses
2025-06-30 14:47:55 +00:00
Stef Walter fed198eaf9 api: Don't HTML escape application/json responses
An HTTP response with Content-Type application/json does not need
to be HTML escaped. Doing this causes encoding issues in the Podman
REST API output as seen in the issue:

Fixes #17769

Remove the HTML escaping from Content-Type: application/json responses.

Signed-off-by: Stef Walter <stef@thewalter.net>
Co-Authored-By: Claude <noreply@anthropic.com>
2025-06-30 12:54:19 +02:00
Paul Holzinger 5786d5f846
fix new lint errors from the docker update
Some new deprecated fields, we still have to set them since clients
might still use them.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-27 16:35:40 +02:00
Paul Holzinger 9d328d8782
pkg/api: remove deadcode
One might think Close() should be called but we are already using
Shutdown() which is the graceful way to stop the server so we don't
actually need Close().

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-26 19:37:13 +02:00
Paul Holzinger 75bad52af5
remove unused ShouldRestart() code
Deadcode should that the ShouldRestart() API endpoint was never wired
into the router so the endpoint did not existed and the bindings called
a non existing endpoint which returnd 404 which the binding code
assumed means no restart.

As such remove all this code as it didn't do anything useful. And IMO
exposing a shouldrestart API always feeled wrong to me. The client
should not have to deal with this.

This commit does not change the behavior but it also does not make an
attempt to fix the broken restart handling with the rmeote client. Given
we do not seem to have any user reports about this it seems it is not
used.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-26 19:37:13 +02:00
openshift-merge-bot[bot] 494287518b
Merge pull request #26467 from ygalblum/secret-create-ignore
Secret create - add ignore option to allow noop
2025-06-26 15:25:52 +00:00
openshift-merge-bot[bot] 683e9b2c94
Merge pull request #26434 from mheon/import_export
Add remote support for `podman volume import` and `podman volume export`
2025-06-25 19:48:14 +00:00
Ygal Blum bfc327a08e Secret create - add ignore option to allow noop
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2025-06-24 15:43:38 -04:00
Matt Heon 98876454cb Refactor `volume import` to support the remote client
As with `volume export`, this was coded up exclusively in cmd/
instead of in libpod. Move it into Libpod, add a REST endpoint,
add bindings, and now everything talks using the ContainerEngine
wiring.

Also similar to `volume export` this also makes things work much
better with volumes that require mounting - we can now guarantee
they're actually mounted, instead of just hoping.

Includes some refactoring of `volume export` as well, to simplify
its implementation and ensure both Import and Export work with
readers/writers, as opposed to just files.

Fixes #26409

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-06-23 13:42:22 -04:00
Giuseppe Scrivano 1f9893817b
volumes: add new --uid and --gid option
they allow to override the owner of the volume.  Differently from
-o=uid= and -o=gid= they are not passed down to the mount operation.

Closes: https://issues.redhat.com/browse/RHEL-76452

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-06-18 15:33:09 +02:00
Matt Heon 63bf454d66 Refactor `podman export` to work with the remote client
Previously, our approach was to inspect the volume, grab its
mountpoint, and tar that up, all in the CLI code. There's no
reason why that has to be in the CLI - if we move it into
Libpod, and add a REST endpoint to stream the tar, we can
enable it for the remote client as well.

As a bonus, previously, we could not properly handle volumes that
needed to be mounted. Now, we can mount the volume if necessary,
and as such export works with more types of volumes, including
volume drivers.

Signed-off-by: Matt Heon <mheon@redhat.com>
2025-06-14 07:42:38 -04:00
Paul Holzinger d44f0afa84
vendor: update github.com/docker/docker to v28.2.2
Two incomptable changes, they removed the BridgeNfIP6tables
and BridgeNfIptables fields so we must drop them. As they are not
important ones that should not cause problems.

Second, they moved to using DockerOCIImageConfig from another new module.
The json format did not chnage so this is not an external API break.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-06-05 12:19:58 +02:00
Lewis Roy 99cfdc04db
feat: Add OCI Artifact support to the Podman REST API
This patch adds a new endpoint to the REST API called "artifacts" with
the following methods:
- Add
- Extract
- Inspect
- List
- Pull
- Push
- Remove

This API will be utilised by the Podman bindings to add OCI Artifact
support to our remote clients.

Jira: https://issues.redhat.com/browse/RUN-2711

Signed-off-by: Lewis Roy <lewis@redhat.com>
2025-06-04 15:49:34 +10:00
Jan Kaluza 3a981915f0 Handle "Entrypoint":[] in compat containers/create API.
When using `docker compose run --entrypoint ''`, docker sends
`"Entrypoint": []` in the JSON. Podman currently treats that
as `nil` and fallback to default image entrypoint.

This is not what is expected by the user. Instead, it should
not use any entrypoint.

This commit fixes it by properly propagating the `[]` downstream
to libpod.

Fixes: #26078

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-05-29 08:45:35 +02:00
Paul Holzinger 66bf98e27c
compat API: respect base_hosts_file containers.conf option
Hard coding to none without checking containers.conf is not a good idea
as users who liked the previous behavior and the podman default behavior
of keeping the hosts entries can no longer do that.

With this commit they can set base_hosts_file = "/etc/hosts" to restore
the previous behavior.

Fixes: https://issues.redhat.com/browse/RHEL-92995

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-05-26 16:16:10 +02:00
openshift-merge-bot[bot] 5629ba8a8d
Merge pull request #26149 from azdle/docker-api-container-status
compat: fix ContainerState.Status JSON values
2025-05-20 17:53:12 +00:00
Patrick Barrett 92a15085cb compat: fix Container State.Status JSON values
This mirrors the conversion currently being done in `LibpodToContainer`
into `LibpodToContainerJSON`, converting podman style statuses to docker
style statuses as defined in their OpenAPI definition:

https://docs.docker.com/reference/api/engine/version/v1.49/#tag/Container/operation/ContainerInspect

Fixes: #17728

Signed-off-by: Patrick Barrett <patrick@psbarrett.com>
2025-05-20 10:22:45 -05:00
openshift-merge-bot[bot] e32b57b1ea
Merge pull request #26115 from inknos/compat-get-info-defaultaddresspool
compat: Add DefaultAddressPools field to GET /info
2025-05-20 14:37:22 +00:00
Nicola Sella 7c0262db3d
compat: Add DefaultAddressPools field to GET /info
Signed-off-by: Nicola Sella <nsella@redhat.com>
2025-05-16 13:16:27 +02:00
Nicola Sella b82f2962c3
compat: Add CgroupnsMode to POST /containers/create
Signed-off-by: Nicola Sella <nsella@redhat.com>
2025-05-15 15:31:16 +02:00
openshift-merge-bot[bot] 857cfb9062
Merge pull request #25861 from cesargoncalves/main
update podman socket output to include also exposed ports
2025-05-06 19:10:36 +00:00
openshift-merge-bot[bot] ce0bac24e5
Merge pull request #25986 from Honny1/fix-unlimited-ulimits
Fix handling of "r_limits" in Podman REST API /libpod/containers/create
2025-04-28 22:27:40 +00:00
openshift-merge-bot[bot] 2679304aa8
Merge pull request #25983 from matejvasek/fix-inherit-label
Fix: inheritlabels=true if query param absent
2025-04-28 16:02:48 +00:00
Jan Rodák e66ff395b7
Fix handling of "r_limits" in Podman REST API /libpod/containers/create
The JSON decoder correctly cannot decode (overflow) negative values (e.g., `-1`) for fields of type `uint64`, as `-1` is used to represent `max` in `POSIXRlimit`. To handle this, we use `tmpSpecGenerator` to decode the request body. The `tmpSpecGenerator` replaces the `POSIXRlimit` type with a `tmpRlimit` type that uses the `json.Number` type for decoding values. The `tmpRlimit` is then converted into the `POSIXRlimit` type and assigned to the `SpecGenerator`.

This approach ensures compatibility with the Podman CLI and remote API, which already handle `-1` by casting it to `uint64` (`uint64(-1)` equals `MaxUint64`) to signify `max`.

Fixes: https://issues.redhat.com/browse/RUN-2859
Fixes: https://github.com/containers/podman/issues/24886

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-04-28 15:02:19 +02:00
Lewis Roy 6e7de438cc
bug: Correct Docker compat REST API image delete endpoint
The Docker `-XDELETE image/$name?force=true` endpoint only removes
containers using an image if they are in a non running state.

In Podman, when forcefully removing images we also forcefully delete
containers using the image including running containers.

This patch changes the Docker image force delete compat API to act like the
Docker API while maintaining commands like `podman rmi -f $imagename`

It also corrects the API return code returned when an image is requested
to be deleted with running containers using it.

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

Signed-off-by: Lewis Roy <lewis@redhat.com>
2025-04-27 20:51:11 +10:00
Cesar Goncalves a969dbd73e
update podman socket output to include also exposed ports
Fixes https://github.com/containers/podman/issues/25851

Co-authored-by: Brent Baude <bbaude@redhat.com>
Signed-off-by: Cesar Goncalves <mail@cesargoncalves.com>
2025-04-27 11:11:28 +01:00
Matej Vašek 0c4d023822
Fix: inheritlabels=true if query param absent
The inheritlabels param must default to true if query param is absent.

Signed-off-by: Matej Vašek <matejvasek@gmail.com>
2025-04-25 19:17:00 +02:00
tomsweeneyredhat 10d768baaf Add inherit-labels option to Build API
Add the inherit-labels option to the build API and tweak the go.mod
after some unhappiness in my sandbox.

Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
2025-04-22 23:06:57 -04:00
Jan Rodák 3cbb718049
Fix compat API in rootless mode ignores ulimits
Fixes: https://github.com/containers/podman/issues/25881

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-04-17 16:11:34 +02:00
Paul Holzinger f26765ceb0
update golangci-lint to v2.1.1
Fixes three new issues found by nilnesserr.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-04-14 19:33:42 +02:00
Kir Kolyshkin 0f975f8526 ci: rm allow-unused from nolintlint settings
This was added by commit 84e42877a ("make lint: re-enable revive"),
making nolintlint became almost useless.

Remove the ungodly amount of unused nolint annotations.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00
Kir Kolyshkin f4f2580b0d ci: remove stylecheck linter
It is to be merged into staticcheck linter in golangci-lint v2.0.0.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00
Kir Kolyshkin 0dddc5e3c0 Apply De Morgan's law
This fixes a bunch of "QF1001: could apply De Morgan's law" warnings
from staticcheck linter.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00
sianao 44cbefff5d fix remove unnecessary err check
Signed-off-by: sianao <me@sianao.site>
2025-03-27 15:27:52 +08:00
openshift-merge-bot[bot] b2285f6d46
Merge pull request #25626 from jankaluza/24875
Add --env and --unsetenv to podman update.
2025-03-21 13:52:17 +00:00
Jan Kaluza 701aade262 Add --env and --unsetenv to podman update.
The --env is used to add new environment variable to container or
override the existing one. The --unsetenv is used to remove
the environment variable.

It is done by sharing "env" and "unsetenv" flags between both
"update" and "create" commands and later handling these flags
in the "update" command handler.

The list of environment variables to add/remove is stored
in newly added variables in the ContainerUpdateOptions.

The Container.Update API call is refactored to take
the ContainerUpdateOptions as an input to limit the number of its
arguments.

The Env and UnsetEnv lists are later handled using the envLib
package and the Container is updated.

The remote API is also extended to handle Env and EnvUnset.

Fixes: #24875

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-03-21 13:15:44 +01:00
Giuseppe Scrivano 88b62d2c27
vendor: update c/common
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-03-20 13:37:19 +01:00
Jan Rodák fff42ac232
Fix HealthCheck log destination, count, and size defaults
GoLang sets unset values to the default value of the type. This means that the destination of the log is an empty string and the count and size are set to 0. However, this means that size and count are unbounded, and this is not the default behavior.

Fixes: https://github.com/containers/podman/issues/25473
Fixes: https://issues.redhat.com/browse/RHEL-83262

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-03-12 21:27:00 +01:00
Paul Holzinger f2606c4230
fix deprecated docker v28 types
A lot of types are moved and now deprecated which causes lint issues.

IDResponse is copied into podman because that has no new 1 to 1
replacement. For some fields that we set as part of the docker API I
added the nolint directive as these fields might be used by API
consumers.

For the other types it is mostly a 1 to 1 move.

ParseUintList is deprecated but we can use the same function from
github.com/containers/storage/pkg/parsers instead.

Note that it containers breaking changes to pkg/bindings which we should
not do generally but given the prevoius commit already has a unavoidable
breaking change we might as well fix the IDResponse issue once now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-11 16:24:34 +01:00
Paul Holzinger 91a08235d1
vendor: update docker v28 and c/{common,image}
Update to the latest c/{common,image} which inclused an update to
docker v28, that update is NOT backwards compatible so I had to fix a
few types.

NOTE: handler.ExecCreateConfig is used directly by the bindings. Thus
this is an API break for pkg/bindings. Including docker types as part of
any stable pkg/bindings API was a very bad idea.

I see no way to avoid that unless we never want to docker v28, which is
not easy as the update comes in from c/image and maybe other packages.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-03-11 16:24:14 +01:00
Jan Rodák 511d912685
Add stopped status for HealthCheck
If the container is stopped and the ongoing HealthCheck has no chance to complete the check is evaluated as stopped.

Fixes: https://issues.redhat.com/browse/RUN-2520
Fixes: https://github.com/containers/podman/issues/25276

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2025-03-03 17:09:30 +01:00
Jakub Panek 4dbbf264c7
Fix reporting summed image size for compat endpoint
Signed-off-by: Jakub Panek <me@panekj.dev>
2025-02-25 04:03:28 +00:00
openshift-merge-bot[bot] 7afb601bd8
Merge pull request #25180 from Luap99/local-exec-detach
podman exec: correctly support detaching
2025-02-03 01:49:58 +00:00
openshift-merge-bot[bot] c131c9d038
Merge pull request #25170 from baude/artifactoptions
Add type and annotations to artifact add
2025-01-31 17:19:18 +00:00
Brent Baude bd061aa2d5 Add type and annotations to artifact add
podman artifact add now supports two new command line switches.

--type string that describes the type of artifact
--annotation string slice in the form of key=val

These new options allow users to "tag" information in on their artifacts
for any number of purposes down the line

RUN-2446

Signed-off-by: Brent Baude <bbaude@redhat.com>
2025-01-31 09:53:03 -06:00
Giuseppe Scrivano 18e29076f7
pkg/api: honor cdi devices from the hostconfig
pass down the devices specifies in the resources block so that CDI
devices in the compose file are honored.

Tested manually with the following compose file:

services:
  testgpupodman_count:
    image: ubuntu:latest
    command: ["nvidia-smi"]
    profiles: [gpu]
    deploy:
      resources:
        reservations:
          devices:
          - driver: nvidia
            count: 1
            capabilities: [gpu]
  testgpupodman_deviceid:
      image: docker.io/ubuntu:latest
      command: ["nvidia-smi"]
      deploy:
        resources:
          reservations:
            devices:
            - driver: cdi
              device_ids: ['nvidia.com/gpu=all']
              capabilities: [gpu]

Closes: https://github.com/containers/podman/issues/19338

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2025-01-31 15:26:09 +01:00
Paul Holzinger f0ef791808
podman exec: correctly support detaching
podman exec support detaching early via the detach key sequence. In that
case the podman process should exit successfully but the container exec
process keeps running.

Now I wrote automated test for both podman run and exec detach but this
uncovered several larger issues:
 - detach sequence parsing is broken[1]
 - podman-remote exec detach is broken[2]
 - detach in general seems to be buggy/racy, seeing lot of flakes that
   fail to restore the terminal and get an EIO instead, i.e.
   "Unable to restore terminal: input/output error"

Thus I cannot add tests for now but this commit should at least fix the
obvoius case as reported by the user so I like to get this in regardless
and I will work through the other issues once I have more time.

Fixes #24895

[1] https://github.com/containers/common/pull/2302
[2] https://github.com/containers/podman/issues/25089

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-31 13:29:04 +01:00
openshift-merge-bot[bot] 8d65d1e9e2
Merge pull request #25102 from Honny1/prune
Clean up after unexpectedly terminated build
2025-01-27 16:52:06 +00:00
openshift-merge-bot[bot] 9403c3d98d
Merge pull request #24678 from rhatdan/manifest
Add podman manifest rm --ignore
2025-01-27 14:52:05 +00:00