Commit graph

2124 commits

Author SHA1 Message Date
Ashley Cui
2cc9af3692 add {{.RunningFor}} placeholder in ps --format
For docker compatibility

Signed-off-by: Ashley Cui <acui@redhat.com>
2020-07-31 11:44:53 -04:00
Paul Holzinger
994dc32942 fix swapped mem_usage/percent fields
Correct the wrong field assignment in `podman stats --format=json`.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-07-31 11:44:16 -04:00
Daniel J Walsh
9b1a7894a1 Don't crash when giving bogus format commands
Currently if you give a bogus flag to --format it will crash
the formatter.  With this change we will get a nice error.

podman images --format '{{ bogus }}'
Error: template: list:1: function "bogus" not defined

versus
 /bin/podman.old images --format '{{ bogus }}'
panic: template: list:1: function "bogus" not defined

goroutine 1 [running]:

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

<MH: Fixed compile after cherry pick>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-31 11:42:40 -04:00
Daniel J Walsh
828b547491 Specifying --ipc=host --pid=host is broken
For some reason we were overwriting memory when handling both
--pid=host and --ipc=host.  Simplified the code to handle this
correctly, and add test to make sure it does not happen again.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-31 11:40:25 -04:00
Anthony Sottile
e0774e65b4 add newline to output in error message
Signed-off-by: Anthony Sottile <asottile@umich.edu>
2020-07-31 11:39:17 -04:00
Paul Holzinger
ae34c63860 replace the html/template package with text/template
Currently some commands use the html/template package.
This can lead to invalid output.
e.g. `system df --verbose` will print `&lt;none&gt;`
instead of `<none>` with an untaged image.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-07-31 11:37:22 -04:00
Matthew Heon
a34888de31 The podman start --attach command should not print ID
Somewhere in the Podman v2 rewrite, we allowed
`podman start --attach` to print the container ID of the started
container after exiting from the attach session (via detach key
or the container exiting naturally). We should never print the ID
when `--attach` is given, which makes the fix simple - make the
print statement conditional on `--attach` not being present.

Wierdly, this only happened with `--interactive` was given to
`podman start`. I don't know why that is, but this resolves the
issue without having to dig any deeper, so I'm content.

Fixes #7055

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-31 11:36:51 -04:00
Daniel J Walsh
8c6a528693 Fix building from http or '-' options
When copying from a URL, podman will download and create a context
directory in a temporary file.  The problem was that this directory
was being removed as soon as the function that created it was returned.

Later the build code would look for content in the temporary directory
and fail to find it, blowing up the build.

By pulling the extraction code back into the build function, we keep the
temporary directory around until the build completes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-31 13:01:45 +02:00
Daniel J Walsh
4d7626cc89 Fix handling of entrypoint
If a user specifies an entrypoint of "" then we should not use the images
entrypoint.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-22 14:53:26 -04:00
Valentin Rothberg
1fb32b9b2f version/info: format: allow more json variants
Allow more variants to yield json output for `podman version` and
`podman info`.  Instead of comparing strings, use a regex and add
unit and e2e tests.

Fixes: #6927
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-22 14:42:53 -04:00
Matthew Heon
0630d19b34 Fix container and pod create commands for remote create
In `podman inspect` output for containers and pods, we include
the command that was used to create the container. This is also
used by `podman generate systemd --new` to generate unit files.

With remote podman, the generated create commands were incorrect
since we sourced directly from os.Args on the server side, which
was guaranteed to be `podman system service` (or some variant
thereof). The solution is to pass the command along in the
Specgen or PodSpecgen, where we can source it from the client's
os.Args.

This will still be VERY iffy for mixed local/remote use (doing a
`podman --remote run ...` on a remote client then a
`podman generate systemd --new` on the server on the same
container will not work, because the `--remote` flag will slip
in) but at the very least the output of `podman inspect` will be
correct. We can look into properly handling `--remote` (parsing
it out would be a little iffy) in a future PR.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>

<MH: Fixed build after cherry-pick>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-22 14:39:41 -04:00
Matthew Heon
0030dd3f75 Ensure sig-proxy default is propagated in start
We properly determined what sig-proxy should be set to, but we
never passed that along to the backend. As such, cases where the
default swapped (mostly when `--attach` was specified but the
`--sig-proxy` flag was not) were not handled correctly

Fixes #6928

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-22 14:34:20 -04:00
Giuseppe Scrivano
e21a6368f9 abi: set default umask and rlimits
the code got lost in the migration to podman 2.0, reintroduce it.

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

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

<MH: Fixed build>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-22 14:05:20 -04:00
Parker Van Roy
92186cbd28 Used reference package with errors for parsing tag
Signed-off-by: Parker Van Roy <pvanroy@redhat.com>
2020-07-22 13:52:53 -04:00
Daniel J Walsh
a5f5e45c4b Add noop function disable-content-trust
People who use docker scripts with Podman see failures
if they use disable-content-trust flag.  This flag already
existed for podman build, adding it to pull/push/create/run.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-22 13:42:56 -04:00
Daniel J Walsh
cb603b8a3e Support default profile for apparmor
Currently you can not apply an ApparmorProfile if you specify
--privileged.  This patch will allow both to be specified
simultaniosly.

By default Apparmor should be disabled if the user
specifies --privileged, but if the user specifies --security apparmor:PROFILE,
with --privileged, we should do both.

Added e2e run_apparmor_test.go

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-22 13:14:15 -04:00
Daniel J Walsh
330e9144bd
Switch references from libpod.conf to containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-21 09:29:01 -04:00
Matthew Heon
9810e586fe Fix a bug where --pids-limit was parsed incorrectly
The --pids-limit flag was using strconv.ParseInt with bad
arguments, resulting in it being unable to parse standard
integers (1024, for example, would produce an 'out of range'
error).

Change the arguments to make sense (base 10, max 32-bit) and
add a test to ensure we don't regress again.

Fixes #6908

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-07-15 10:04:42 -04:00
OpenShift Merge Robot
ea7a6101ef
Merge pull request #6873 from baude/v2.0disableconnection
remove podman system connection
2020-07-07 06:03:08 -04:00
Matthew Heon
8ab0abbb06 Fix bug where podman mount didn't error as rootless
We require that rootless `podman mount` be run inside a shell
spawned by `podman unshare` (which gives us a mount namespace
which actually lets other commands use the mounted filesystem).

The fix is simple - we need to mark the command as requiring the
rootless user namespace not be configured, so we can test for it
later as part of the mount code and error if we needed to make
one.

Disable rootless tests as part of this - they were never expected
to work.

Fixes #6856

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-06 16:59:05 -04:00
Brent Baude
66e1626282 remove podman system connection
podman system connection was panic'ing and not working as expected.  we are temporarily removing to as to not confuse users until we can fix it and prevent regressions with integrations tests.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-07-06 15:36:17 -05:00
OpenShift Merge Robot
e3e2b1e659
Merge pull request #6871 from mheon/202_backports
Backports for v2.0.2
2020-07-06 15:55:15 -04:00
Matthew Heon
2fb9bb20df Fix imports to ensure v2 is used with libpod
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-06 14:44:40 -04:00
Jhon Honce
8dd26289bf Fixes --remote flag issues
* --remote, --url and --identity are now anchored to podman command.
  Subcommands should no longer have issues
* TraverseChildren now set to V1 expectations
* Latest flag now has helper function. Now has consistent usage.
* IsRemote() uses cobra parser to determin if --remote is given
* Moved validation functions from parser pkg to validate pkg
*

Fixes #6598
Fixes #6704

Signed-off-by: Jhon Honce <jhonce@redhat.com>

<MH: Fixed import issues>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-07-06 14:14:53 -04:00
Daniel J Walsh
c4023a9302
Pids-limit should only be set if the user set it
Currently we are sending over pids-limits from the user even if they
never modified the defaults.  The pids limit should be set at the server
side unless modified by the user.

This issue has led to failures on systems that were running with cgroups V1.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-06 14:14:48 -04:00
Brent Baude
de6a8609a8 Set console mode for windows
Windows terminal handling is different than darwin and linux.  It needs to have the terminal mode set to enable virtual terminal processing.  This allows colors and other things to work.

Signed-off-by: Brent Baude <bbaude@redhat.com>

<MH: Tweaked imports to compile>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-07-06 13:41:39 -04:00
Matthew Heon
1c02d5ab89 Allow empty host port in --publish flag
I didn't believe that this was actually legal, but it looks like
it is. And, unlike our previous understanding (host port being
empty means just use container port), empty host port actually
carries the same meaning as `--expose` + `--publish-all` (that
is, assign a random host port to the given container port). This
requires a significant rework of our port handling code to handle
this new case. I don't foresee this being commonly used, so I
optimized having a fixed port number as fast path, which this
random assignment code running after the main port handling code
only if necessary.

Fixes #6806

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-07-06 13:37:27 -04:00
Daniel J Walsh
0c4a734353 Set TMPDIR to /var/tmp by default if not set
Containers/image will use TMPDIR for the location of pulled layer blobs.
If TMPDIR is not set, it will use /tmp.  Since this is known to be of
limited space on most systems, we change the default to /var/tmp
if the user has not told the tools where to store temporary files.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-06 13:35:33 -04:00
Valentin Rothberg
d59ef41194 auto-update: clarify systemd-unit requirements
Clarify in the help message and the man page that auto updates only work
with systemd units that are similar to the ones from `generate systemd
--new`.  Units that merely start/stop a container do not work as they
will use the same image.

Fixes: #6793
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 13:08:56 -04:00
Paul Holzinger
0e547a4cc3 podman ps truncate the command
With a long create command the
output from ps is basically unreadable.

This is a regression that was introduced with Podman 2.0.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-07-06 13:07:29 -04:00
Valentin Rothberg
2d74811520 move go module to v2
With the advent of Podman 2.0.0 we crossed the magical barrier of go
modules. While we were able to continue importing all packages inside
of the project, the project could not be vendored anymore from the
outside.

Move the go module to new major version and change all imports to
github.com/containers/libpod/v2. The renaming of the imports
was done via gomove [1].

[1] https://github.com/KSubedi/gomove

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-07-06 15:52:17 +02:00
Lokesh Mandvekar
9eebfd40ae Account for non-default port number in image name
Previously, if an image was tagged with the format
$REGISTRY:$PORT/$REPO:$TAG,
then `podman images` would display $PORT/$REPO:$TAG under the "TAG"
field.

This commit correctly displays $REGISTRY:$PORT/$REPO under the
"REPOSITORY" field while the "TAG" field only displays $TAG.

Signed-off-by: Lokesh Mandvekar <lsm5@fedoraproject.org>

Fixes: gh#6665
(cherry picked from commit 71f6dd47dd)
2020-06-27 14:05:00 -04:00
Daniel J Walsh
8bb986137b Fix inspect to display multiple label: changes
If the user runs a container like

podman run --security-opt seccomp=unconfined --security-opt label=type:spc_t --security-opt label=level:s0 ...

Podman inspect was only showing the second option

This change will show

            "SecurityOpt": [
                "label=type:spc_t,label=level:s0:c60",
                "seccomp=unconfined"
            ],

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-25 15:42:42 -04:00
Valentin Rothberg
68543bbece podman run/create: support all transports
Support all image transports in podman run/create.  It seems we
regressed with v2 on that.  Also add tests to make sure we're
not regressing again.

Fixes: #6744
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-25 15:41:13 -04:00
Jhon Honce
9de1581e93 Revert sending --remote flag to containers
* quick --remote fix, sent --remote to ctnrs as argument

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-25 15:37:26 -04:00
Matthew Heon
eb9fd40d21 Set stop signal to 15 when not explicitly set
When going through the output of `podman inspect` to try and
identify another issue, I noticed that Podman 2.0 was setting
StopSignal to 0 on containers by default. After chasing it
through the command line and SpecGen, I determined that we were
actually not setting a default in Libpod, which is strange
because I swear we used to do that. I re-added the disappeared
default and now all is well again.

Also, while I was looking for the bug in SpecGen, I found a bunch
of TODOs that have already been done. Eliminate the comments for
these.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 14:47:59 -04:00
Jhon Honce
d26662484b Fix ssh-agent support
* An identity of "" implies ssh-agent and user/password to be used
* Fixed example

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-24 14:43:31 -04:00
Brent Baude
9a4517b370 Add JSON output field for ps
the toolbox team needs a field in our ps json that represents a human readable time.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-24 14:41:24 -04:00
Jhon Honce
61bd645732 V2 podman system connection
* Implement command
* Refactor podman-remote to pull from containers.conf by default
* podman-remote defaults to --remote being true
* Write podman-system-connection.1.md

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-24 14:41:09 -04:00
Brent Baude
f81ad0058c wip
Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-24 14:41:00 -04:00
Valentin Rothberg
cd0b18c24f image load: no args required
Disable the args requirement of `image load`.  Instead of requiring a
lower bound, we really need an upper one with at most 1 argument.
Extend the system tests to prevent future regressions.

Fixes: #6718
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-24 14:39:45 -04:00
Matthew Heon
8fbfffc082 Re-add PODMAN_USERNS environment variable
This was lost during the Podman 2.0 migration. Turns out to be a
very easy fix, fortunately - we want to use the environment var
if not explicitly overridden.

Fixes #6705

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 14:38:23 -04:00
Matthew Heon
0b4dcc7a36 Fix conflicts between privileged and other flags
The `--privileged` flag does not conflict with `--group-add`
(this one was breaking Toolbox) and does not conflict with most
parts of `--security-opt` (this was breaking Openstack).

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-06-24 14:37:35 -04:00
Daniel J Walsh
37abb88aa0 Fix podman build handling of --http-proxy flag
Also fixed a todo for handling of cgroup manager while I was in there.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-24 14:32:43 -04:00
Jhon Honce
ea8e61e4eb Fixes #6670
* Sort images for -q option, removing duplicate id's
* Sort images for --format json

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-19 08:57:12 -07:00
Valentin Rothberg
bba433ed92 podman images --format json: pretty print
Pretty print the JSON output when listing images.  We regressed on that
during v2 development. The indentation is now identical to the one of
Podman v1.9.3.

Fixes: #6687
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-06-19 15:30:32 +02:00
Matthew Heon
43ead88e81 Podman system service is no longer experimental
As such, we can remove the warnings logs that previously printed
every time it was run.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-06-17 17:39:49 -04:00
OpenShift Merge Robot
78ad57ebd3
Merge pull request #6636 from mheon/add_warnings
Re-add resource limit warnings to Specgen
2020-06-17 16:51:51 +02:00
OpenShift Merge Robot
200afe7a94
Merge pull request #6583 from mheon/inspect_ctr_before_img
Fix podman inspect on overlapping/missing objects
2020-06-17 16:27:15 +02:00
OpenShift Merge Robot
38391ed25f
Merge pull request #6622 from goochjj/podman_fix_init
Fix --init and --init-path
2020-06-17 15:42:30 +02:00