mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
Merge pull request #7224 from rhatdan/remove
Handle podman-remote run --rm
This commit is contained in:
@ -500,9 +500,6 @@ func (ic *ContainerEngine) ContainerList(ctx context.Context, options entities.C
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.ContainerRunOptions) (*entities.ContainerRunReport, error) {
|
func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.ContainerRunOptions) (*entities.ContainerRunReport, error) {
|
||||||
if opts.Rm {
|
|
||||||
logrus.Info("the remote client does not support --rm yet")
|
|
||||||
}
|
|
||||||
con, err := containers.CreateWithSpec(ic.ClientCxt, opts.Spec)
|
con, err := containers.CreateWithSpec(ic.ClientCxt, opts.Spec)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -526,6 +523,17 @@ func (ic *ContainerEngine) ContainerRun(ctx context.Context, opts entities.Conta
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
report.ExitCode = define.ExitCode(err)
|
report.ExitCode = define.ExitCode(err)
|
||||||
}
|
}
|
||||||
|
if opts.Rm {
|
||||||
|
if err := containers.Remove(ic.ClientCxt, con.ID, bindings.PFalse, bindings.PTrue); err != nil {
|
||||||
|
if errors.Cause(err) == define.ErrNoSuchCtr ||
|
||||||
|
errors.Cause(err) == define.ErrCtrRemoved {
|
||||||
|
logrus.Warnf("Container %s does not exist: %v", con.ID, err)
|
||||||
|
} else {
|
||||||
|
logrus.Errorf("Error removing container %s: %v", con.ID, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return &report, err
|
return &report, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,8 +96,6 @@ echo $rand | 0 | $rand
|
|||||||
# Believe it or not, 'sh -c' resulted in different behavior
|
# Believe it or not, 'sh -c' resulted in different behavior
|
||||||
run_podman 0 run --rm $IMAGE sh -c /bin/true
|
run_podman 0 run --rm $IMAGE sh -c /bin/true
|
||||||
run_podman 1 run --rm $IMAGE sh -c /bin/false
|
run_podman 1 run --rm $IMAGE sh -c /bin/false
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@test "podman run --name" {
|
@test "podman run --name" {
|
||||||
@ -266,8 +264,6 @@ echo $rand | 0 | $rand
|
|||||||
done
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# #6829 : add username to /etc/passwd inside container if --userns=keep-id
|
# #6829 : add username to /etc/passwd inside container if --userns=keep-id
|
||||||
@ -292,8 +288,6 @@ echo $rand | 0 | $rand
|
|||||||
run_podman run --rm --privileged --userns=keep-id --user=0 $IMAGE id -un
|
run_podman run --rm --privileged --userns=keep-id --user=0 $IMAGE id -un
|
||||||
remove_same_dev_warning # grumble
|
remove_same_dev_warning # grumble
|
||||||
is "$output" "root" "--user=0 overrides keep-id"
|
is "$output" "root" "--user=0 overrides keep-id"
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# #6991 : /etc/passwd is modifiable
|
# #6991 : /etc/passwd is modifiable
|
||||||
|
@ -91,7 +91,6 @@ ADD https://github.com/containers/podman/blob/master/README.md /tmp/
|
|||||||
EOF
|
EOF
|
||||||
run_podman build -t add_url $tmpdir
|
run_podman build -t add_url $tmpdir
|
||||||
run_podman run --rm add_url stat /tmp/README.md
|
run_podman run --rm add_url stat /tmp/README.md
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman rmi -f add_url
|
run_podman rmi -f add_url
|
||||||
|
|
||||||
# Now test COPY. That should fail.
|
# Now test COPY. That should fail.
|
||||||
|
@ -93,7 +93,6 @@ Labels.l | $mylabel
|
|||||||
is "$(<$mountpoint/myfile)" "$rand" "we see content created in container"
|
is "$(<$mountpoint/myfile)" "$rand" "we see content created in container"
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman volume rm $myvolume
|
run_podman volume rm $myvolume
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,7 +134,6 @@ EOF
|
|||||||
is "$output" "got here -$rand-" "script in volume is runnable with default (exec)"
|
is "$output" "got here -$rand-" "script in volume is runnable with default (exec)"
|
||||||
|
|
||||||
# Clean up
|
# Clean up
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman volume rm $myvolume
|
run_podman volume rm $myvolume
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +171,6 @@ EOF
|
|||||||
run_podman run --rm -v $myvol:/myvol:z $IMAGE \
|
run_podman run --rm -v $myvol:/myvol:z $IMAGE \
|
||||||
sh -c "cp /myvol/myfile /myvol/myfile2"
|
sh -c "cp /myvol/myfile /myvol/myfile2"
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman volume rm $myvol
|
run_podman volume rm $myvol
|
||||||
|
|
||||||
# Autocreated volumes should also work with keep-id
|
# Autocreated volumes should also work with keep-id
|
||||||
@ -182,7 +179,6 @@ EOF
|
|||||||
run_podman run --rm -v $myvol:/myvol:z --userns=keep-id $IMAGE \
|
run_podman run --rm -v $myvol:/myvol:z --userns=keep-id $IMAGE \
|
||||||
touch /myvol/myfile
|
touch /myvol/myfile
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman volume rm $myvol
|
run_podman volume rm $myvol
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,6 @@ function teardown() {
|
|||||||
is "$output" "$message" "message sent from one container to another"
|
is "$output" "$message" "message sent from one container to another"
|
||||||
|
|
||||||
# Clean up. First the nc -l container...
|
# Clean up. First the nc -l container...
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman rm $cid1
|
run_podman rm $cid1
|
||||||
|
|
||||||
# ...then, from pause container, find the image ID of the pause image...
|
# ...then, from pause container, find the image ID of the pause image...
|
||||||
@ -104,7 +103,6 @@ function teardown() {
|
|||||||
pause_iid="$output"
|
pause_iid="$output"
|
||||||
|
|
||||||
# ...then rm the pod, then rmi the pause image so we don't leave strays.
|
# ...then rm the pod, then rmi the pause image so we don't leave strays.
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman pod rm $podname
|
run_podman pod rm $podname
|
||||||
run_podman rmi $pause_iid
|
run_podman rmi $pause_iid
|
||||||
|
|
||||||
@ -215,7 +213,6 @@ function random_ip() {
|
|||||||
is "$output" ".*options $dns_opt" "--dns-opt was added"
|
is "$output" ".*options $dns_opt" "--dns-opt was added"
|
||||||
|
|
||||||
# pod inspect
|
# pod inspect
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
run_podman pod inspect --format '{{.Name}}: {{.ID}} : {{.NumContainers}} : {{.Labels}}' mypod
|
run_podman pod inspect --format '{{.Name}}: {{.ID}} : {{.NumContainers}} : {{.Labels}}' mypod
|
||||||
is "$output" "mypod: $pod_id : 1 : map\[${labelname}:${labelvalue}]" \
|
is "$output" "mypod: $pod_id : 1 : map\[${labelname}:${labelvalue}]" \
|
||||||
"pod inspect --format ..."
|
"pod inspect --format ..."
|
||||||
|
@ -10,8 +10,6 @@ load helpers
|
|||||||
# Error: invalid argument "true=\"false\"" for "-l, --label" \
|
# Error: invalid argument "true=\"false\"" for "-l, --label" \
|
||||||
# flag: parse error on line 1, column 5: bare " in non-quoted-field
|
# flag: parse error on line 1, column 5: bare " in non-quoted-field
|
||||||
run_podman run --rm --label 'true="false"' $IMAGE true
|
run_podman run --rm --label 'true="false"' $IMAGE true
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
@ -165,8 +165,6 @@ EOF
|
|||||||
die "$path: Unknown file type '$type'"
|
die "$path: Unknown file type '$type'"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# vim: filetype=sh
|
# vim: filetype=sh
|
||||||
|
@ -16,7 +16,6 @@ function check_label() {
|
|||||||
# FIXME: it'd be nice to specify the command to run, e.g. 'ls -dZ /',
|
# FIXME: it'd be nice to specify the command to run, e.g. 'ls -dZ /',
|
||||||
# but alpine ls (from busybox) doesn't support -Z
|
# but alpine ls (from busybox) doesn't support -Z
|
||||||
run_podman run --rm $args $IMAGE cat -v /proc/self/attr/current
|
run_podman run --rm $args $IMAGE cat -v /proc/self/attr/current
|
||||||
if is_remote; then sleep 2;fi # FIXME: pending #7119
|
|
||||||
|
|
||||||
# FIXME: on some CI systems, 'run --privileged' emits a spurious
|
# FIXME: on some CI systems, 'run --privileged' emits a spurious
|
||||||
# warning line about dup devices. Ignore it.
|
# warning line about dup devices. Ignore it.
|
||||||
|
Reference in New Issue
Block a user