Commit graph

2148 commits

Author SHA1 Message Date
Jhon Honce
b64d29bdf2 Remove help/usage from --remote pre-check
--remote pre-check was providing usage context, which was also being
provided by the root podman command.

Fixes #7273

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-30 15:39:01 +02:00
Jhon Honce
33cf7aec51 Refactor parsing to not require --remote to be first
Use cobra.Command.FParseErrWhitelist to no longer require --remote to be
the first argument in flags when using CLI

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-30 12:11:19 +02:00
OpenShift Merge Robot
3ae1cd806c
Merge pull request #7491 from Luap99/2.0-remoteflag
Enable --remote flag v2.0
2020-08-28 15:34:30 -04:00
Daniel J Walsh
e17cd49a78 Enable --remote flag
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-28 18:24:09 +02:00
Brent Baude
31180fa2b1 podman-remote fixes for msi and client
correct small typo that sets the path on windows via the msi xml.

in the remote client, prompt for SSH password when no identity or alternate means of authentication are provided.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-25 15:20:27 -05:00
OpenShift Merge Robot
11372c4c4d
Merge pull request #7363 from mheon/lets_try_this_again
Lets try this again: v2.0.5 backports, round 2
2020-08-21 12:58:55 +02:00
Paul Holzinger
7fc3c25410 fix pod creation with "new:" syntax followup + allow hostname
Fixes: 4c75fe3f70 ("fix pod creation with "new:" syntax")

Commit 4c75fe3f70 passes all net options to the pod but forgot
to unset the options for the container creation. This leads to
erros when using flags like `--ip` since we tried setting
the ip on the pod and container which obviously fails.

I didn't notice the bug because we don't throw an error when
specifing port bindings on a container which joins the pods
network namespace. (#7373)

Also allow the use of `--hostname` and pass that option to the
pod and unset it for the container. The container has to use
the pods hostname anyway. This would error otherwise.

Added tests to prevent regression.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-20 14:59:21 -04:00
Daniel J Walsh
4e31c8136d
Cleanup handling of podman mount/unmount
We should default to the user name unmount rather then the internal
name of umount.

Also User namespace was not being handled correctly. We want to inform
the user that if they do a mount when in rootless mode that they have
to be first in the podman unshare state.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-20 13:35:11 -04:00
Matthew Heon
de75ae29ff Fix imports (podman -> libpod for v2.0 branch)
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 13:21:17 -04:00
Daniel J Walsh
bcd9b8125c Add support for --connection
* override --url and/or --identity fields from containers.conf
* --connection flag has higher precedence than ActiveService from
containers.conf. Which is set via podman system connection default
* Add newline to error message printed on stderr
* Added --connection to bash completion and documentation
* Updated bindings to query server in case of no path or /

Closes #jira-991
Fixes #7276

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

Squashed commits to work around CI issue

<MH: Fixed rebase conflicts on v2.0>

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:42:28 -04:00
Brent Baude
14379d6dbd remove --latest for all remote commands
instead of hiding the latest options for podman-remote or catching an error if podman --remote <cmd> -l is used, we no longer add the latest option to any remote command.  podman will error with a "unknown flag" option.

Fixes: #7127

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-20 12:40:08 -04:00
Jhon Honce
ee956b04b0 [WIP] Refactor podman system connection
* Add support to manage multiple connections
  * Add connection
  * Remove connection
  * Rename connection
  * Set connection as default
  * Add markdown/man pages
* Fix recursion in hack/xref-helpmsgs-manpages

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

<MH: Fixed build after rebase>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Jhon Honce
7c13b8c12f Fix podman system connection panic
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
b216b3391c Revert "remove podman system connection"
This reverts commit 66e1626282. We
are reenabling podman-system-connection.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Matthew Heon
23348e7f31 Ensure DefaultEnvVariables is used in Specgen
When we rewrote Podman's pkg/spec, one of the things that was
lost was our use of a set of default environment variables, that
ensure all containers have at least $PATH and $TERM set.

While we're in the process of re-adding it, change it from a
variable to a function, so we can ensure the Join function does
not overwrite it and corrupt the defaults.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-20 12:16:53 -04:00
Jhon Honce
35d2db8072 Default .Repository and .Tag values to <none>
Refactor the processing of Repository and Tag fields to default to <none>
when printing via --format flag. Previously, the default format would
print <none> but --format {{.Tag}} would not in some cases.

Fixes #7123

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-20 12:16:53 -04:00
Matthew Heon
32f0c8f624 Do not use image CMD if user gave ENTRYPOINT
This matches Docker behavior, and seems to make sense - the CMD
may have been specific to the original entrypoint and probably
does not make sense if it was changed.

While we're in here, greatly simplify the logic for populating
the SpecGen's Command. We create the full command when making the
OCI spec, so the client should not be doing any more than setting
it to the Command the user passed in, and completely ignoring
ENTRYPOINT.

Fixes #7115

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-20 12:16:53 -04:00
Qi Wang
34f4a892e4 podman save use named pipe
podman save uses named pipe as output path, not directly using /dev/stdout.
fix #7017

Signed-off-by: Qi Wang <qiwan@redhat.com>

<MH: Corrected imports during cherry-pick>

Signed-off-by: Matt Heon <matthew.heon@pm.me>
2020-08-20 12:16:52 -04:00
Valentin Rothberg
524ae12977 vendor c/image v5.5.2
Enable pagination until the search result reaches the limit, instead of
returning default 100 limit from registry API.

BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1866153
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-08-20 10:12:27 +02:00
Daniel J Walsh
3dfd8630a5 Add username to /etc/passwd inside of container if --userns keep-id
If I enter a continer with --userns keep-id, my UID will be present
inside of the container, but most likely my user will not be defined.

This patch will take information about the user and stick it into the
container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-08-11 14:58:29 +02:00
Paul Holzinger
895e0d0e2e fix pod creation with "new:" syntax
When you execute podman create/run with the --pod new:<name> syntax
the pod was created but the namespaces where not shared and
therefore containers could not communicate over localhost.

Add the default namespaces and pass the network options to the
pod create options.

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2020-08-11 13:53:23 +02:00
Jhon Honce
3262f77406 Fix podman service --valink timeout
Documentation and unit files call for a millisecond timeout while the
code was using a second resolution.  Code change is smaller given
varlink has been deprecated.

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-08-11 13:53:23 +02:00
zhangguanzhang
85d7cb5fd4 implement the exitcode when start a container with attach
Signed-off-by: zhangguanzhang <zhangguanzhang@qq.com>
2020-08-11 12:15:24 +02:00
Matthew Heon
d6442f5f57 Do not set host IP on ports when 0.0.0.0 requested
Docker and CNI have very different ideas of what 0.0.0.0 means.
Docker takes it to be 0.0.0.0/0 - that is, bind to every IPv4
address on the host. CNI (and, thus, root Podman) take it to mean
the literal IP 0.0.0.0. Instead, CNI interprets the empty string
("") as "bind to all IPs".

We could ask CNI to change, but given this is established
behavior, that's unlikely. Instead, let's just catch 0.0.0.0 and
turn it into "" when we parse ports.

Fixes #7014

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-08-11 12:15:24 +02:00
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