summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd/podman/root.go5
-rw-r--r--docs/source/markdown/podman.1.md5
-rw-r--r--pkg/domain/entities/engine.go1
-rw-r--r--test/system/030-run.bats15
-rw-r--r--test/system/050-stop.bats5
-rw-r--r--test/system/080-pause.bats3
-rw-r--r--test/system/200-pod.bats6
-rw-r--r--test/system/500-networking.bats6
8 files changed, 41 insertions, 5 deletions
diff --git a/cmd/podman/root.go b/cmd/podman/root.go
index b695443c2..1de937ca5 100644
--- a/cmd/podman/root.go
+++ b/cmd/podman/root.go
@@ -114,6 +114,10 @@ func persistentPreRunE(cmd *cobra.Command, args []string) error {
}
cfg := registry.PodmanConfig()
+ if cfg.NoOut {
+ null, _ := os.Open(os.DevNull)
+ os.Stdout = null
+ }
// Currently it is only possible to restore a container with the same runtime
// as used for checkpointing. It should be possible to make crun and runc
@@ -343,6 +347,7 @@ func rootFlags(cmd *cobra.Command, opts *entities.PodmanConfig) {
lFlags.StringVar(&opts.Identity, identityFlagName, ident, "path to SSH identity file, (CONTAINER_SSHKEY)")
_ = cmd.RegisterFlagCompletionFunc(identityFlagName, completion.AutocompleteDefault)
+ lFlags.BoolVar(&opts.NoOut, "noout", false, "do not output to stdout")
lFlags.BoolVarP(&opts.Remote, "remote", "r", registry.IsRemote(), "Access remote Podman service")
pFlags := cmd.PersistentFlags()
if registry.IsRemote() {
diff --git a/docs/source/markdown/podman.1.md b/docs/source/markdown/podman.1.md
index daa8212c5..9f85ebda3 100644
--- a/docs/source/markdown/podman.1.md
+++ b/docs/source/markdown/podman.1.md
@@ -92,6 +92,11 @@ When namespace is set, created containers and pods will join the given namespace
#### **--network-cmd-path**=*path*
Path to the command binary to use for setting up a network. It is currently only used for setting up a slirp4netns network. If "" is used then the binary is looked up using the $PATH environment variable.
+#### **--noout**
+
+Redirect stdout to /dev/null. This command will prevent all stdout from the Podman command. The **--noout** option will not block stderr or stdout from containers.
+
+
#### **--remote**, **-r**
When true, access to the Podman service will be remote. Defaults to false.
Settings can be modified in the containers.conf file. If the CONTAINER_HOST
diff --git a/pkg/domain/entities/engine.go b/pkg/domain/entities/engine.go
index a8023f7cf..055af7ff9 100644
--- a/pkg/domain/entities/engine.go
+++ b/pkg/domain/entities/engine.go
@@ -40,6 +40,7 @@ type PodmanConfig struct {
Identity string // ssh identity for connecting to server
MaxWorks int // maximum number of parallel threads
MemoryProfile string // Hidden: Should memory profile be taken
+ NoOut bool // Don't output to stdout
RegistriesConf string // allows for specifying a custom registries.conf
Remote bool // Connection to Podman API Service will use RESTful API
RuntimePath string // --runtime flag will set Engine.RuntimePath
diff --git a/test/system/030-run.bats b/test/system/030-run.bats
index feca5370b..afcda3d3c 100644
--- a/test/system/030-run.bats
+++ b/test/system/030-run.bats
@@ -509,6 +509,21 @@ json-file | f
rm -f $new_runtime
}
+@test "podman --noout run should print output" {
+ run_podman --noout run -d --name test $IMAGE echo hi
+ is "$output" "" "output should be empty"
+ run_podman wait test
+ run_podman --noout rm test
+ is "$output" "" "output should be empty"
+}
+
+@test "podman --noout create should print output" {
+ run_podman --noout create --name test $IMAGE echo hi
+ is "$output" "" "output should be empty"
+ run_podman --noout rm test
+ is "$output" "" "output should be empty"
+}
+
# Regression test for issue #8082
@test "podman run : look up correct image name" {
# Create a 2nd tag for the local image. Force to lower case, and apply it.
diff --git a/test/system/050-stop.bats b/test/system/050-stop.bats
index e049da518..7dd8f98e8 100644
--- a/test/system/050-stop.bats
+++ b/test/system/050-stop.bats
@@ -173,4 +173,9 @@ load helpers
is "$output" ".*StopSignal SIGTERM failed to stop container stopme in 1 seconds, resorting to SIGKILL" "stopping container should print warning"
}
+@test "podman stop --noout" {
+ run_podman run --rm --name stopme -d $IMAGE top
+ run_podman --noout stop -t 0 stopme
+ is "$output" "" "output should be empty"
+}
# vim: filetype=sh
diff --git a/test/system/080-pause.bats b/test/system/080-pause.bats
index 857c8bbf4..57f390a74 100644
--- a/test/system/080-pause.bats
+++ b/test/system/080-pause.bats
@@ -21,7 +21,8 @@ load helpers
# time to write a new post-restart time value. Pause by CID, unpause
# by name, just to exercise code paths. While paused, check 'ps'
# and 'inspect', then check again after restarting.
- run_podman pause $cid
+ run_podman --noout pause $cid
+ is "$output" "" "output should be empty"
run_podman inspect --format '{{.State.Status}}' $cid
is "$output" "paused" "podman inspect .State.Status"
sleep 3
diff --git a/test/system/200-pod.bats b/test/system/200-pod.bats
index 6abdf9779..4a3337e57 100644
--- a/test/system/200-pod.bats
+++ b/test/system/200-pod.bats
@@ -57,7 +57,8 @@ function teardown() {
fi
# Clean up
- run_podman pod rm -f -t 0 $podid
+ run_podman --noout pod rm -f -t 0 $podid
+ is "$output" "" "output should be empty"
}
@@ -330,7 +331,8 @@ EOF
# Note that the internal pause image is built even when --infra-image is
# set to the K8s one.
- run_podman pod create --name $pod_name --infra-name "$infra_name" --infra-image "k8s.gcr.io/pause:3.5"
+ run_podman --noout pod create --name $pod_name --infra-name "$infra_name" --infra-image "k8s.gcr.io/pause:3.5"
+ is "$output" "" "output should be empty"
run_podman '?' pod create --infra-name "$infra_name"
if [ $status -eq 0 ]; then
die "Podman should fail when user try to create two pods with the same infra-name value"
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats
index 2b5ad44dc..5a721c965 100644
--- a/test/system/500-networking.bats
+++ b/test/system/500-networking.bats
@@ -332,7 +332,8 @@ load helpers
is_rootless || skip "only meaningful for rootless"
local mynetname=testnet-$(random_string 10)
- run_podman network create $mynetname
+ run_podman --noout network create $mynetname
+ is "$output" "" "output should be empty"
# Test that rootless cni adds /usr/sbin to $PATH
# iptables is located under /usr/sbin and is needed for the CNI plugins.
@@ -340,7 +341,8 @@ load helpers
PATH=/usr/local/bin:/usr/bin run_podman run --rm --network $mynetname $IMAGE ip addr
is "$output" ".*eth0.*" "Interface eth0 not found in ip addr output"
- run_podman network rm -t 0 -f $mynetname
+ run_podman --noout network rm -t 0 -f $mynetname
+ is "$output" "" "output should be empty"
}
@test "podman ipv6 in /etc/resolv.conf" {