containers / containers/toolbox

Optionally make exec session terminate with parent

Open
#1,204 15 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
3.5k
Forks
262
Avg merge
3d 1h
Merged PRs (30d)
1

Description

**Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)**

/kind feature

**Description**

Add a flag to `podman exec` to make exec session terminate with parent, similar to [bubblewrap](https://github.com/containers/bubblewrap)'s [`bwrap --die-with-parent`](https://github.com/containers/bubblewrap/commit/b6370de0fc4be6bb801206e39437ad1f2f5c0be7).

Immutable distributions make use of `toolbox` / `distrobox` to provide a mutable environment. A common use is to run commands directly within container (`toolbox run [COMMAND]` / `distrobox enter -- [COMMAND]`), since they use exec session, they have the same limitation of not terminating child-proceess when terminal emulator is closed.

**Steps to reproduce the issue:**

1. Open System Monitor / Task Manager equivilent in your desktop environment, search for `sleep`

2. Run the following command in your terminal emulator (either one will work):

podman:

```bash
podman run --rm -it \
--name debian \
--entrypoint /bin/sh \
docker.io/library/debian:11

# In a new terminal emulator window
podman exec debian sleep 30
```

toolbox:

```bash
toolbox create
toolbox run sleep 30
```

distrobox:

```bash
distrobox create
distrobox enter -- sleep 30
```

3. Then try to close terminal emulator, it'll prompt something like this:

![image](https://user-images.githubusercontent.com/40300931/191938419-18d5f1e0-7daf-4946-beeb-f2aa06cf07c1.png)

4. Insist closing it, then look at System Monitor

**Describe the results you received:**

`sleep 30` still runs within container.

**Describe the results you expected:**

Nah, this is expected, hence this feature request.

**Additional information you deem important (e.g. issue happens only occasionally):**

**Output of `podman version`:**

```
Client: Podman Engine
Version: 4.2.1
API Version: 4.2.1
Go Version: go1.18.5
Built: Thu Sep 8 03:58:19 2022
OS/Arch: linux/amd64
```

**Output of `podman info`:**

Click me

```
host:
arch: amd64
buildahVersion: 1.27.0
cgroupControllers:
- cpu
- io
- memory
- pids
cgroupManager: systemd
cgroupVersion: v2
conmon:
package: conmon-2.1.4-3.fc36.x86_64
path: /usr/bin/conmon
version: 'conmon version 2.1.4, commit: '
cpuUtilization:
idlePercent: 60.53
systemPercent: 23.27
userPercent: 16.2
cpus: 4
distribution:
distribution: fedora
variant: silverblue
version: "36"
eventLogger: journald
hostname: fedora
idMappings:
gidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
uidmap:
- container_id: 0
host_id: 1000
size: 1
- container_id: 1
host_id: 100000
size: 65536
kernel: 6.0.5-200.fc36.x86_64
linkmode: dynamic
logDriver: journald
memFree: 224858112
memTotal: 16705081344
networkBackend: netavark
ociRuntime:
name: crun
package: crun-1.6-2.fc36.x86_64
path: /usr/bin/crun
version: |-
crun version 1.6
commit: 18cf2efbb8feb2b2f20e316520e0fd0b6c41ef4d
spec: 1.0.0
+SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
os: linux
remoteSocket:
exists: true
path: /run/user/1000/podman/podman.sock
security:
apparmorEnabled: false
capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
rootless: true
seccompEnabled: true
seccompProfilePath: /usr/share/containers/seccomp.json
selinuxEnabled: true
serviceIsRemote: false
slirp4netns:
executable: /usr/bin/slirp4netns
package: slirp4netns-1.2.0-0.2.beta.0.fc36.x86_64
version: |-
slirp4netns version 1.2.0-beta.0
commit: 477db14a24ff1a3de3a705e51ca2c4c1fe3dda64
libslirp: 4.6.1
SLIRP_CONFIG_VERSION_MAX: 3
libseccomp: 2.5.3
swapFree: 28844679168
swapTotal: 34359734272
uptime: 42h 55m 22.00s (Approximately 1.75 days)
plugins:
authorization: null
log:
- k8s-file
- none
- passthrough
- journald
network:
- bridge
- macvlan
volume:
- local
registries:
search:
- registry.fedoraproject.org
- registry.access.redhat.com
- docker.io
- quay.io
store:
configFile: /var/home/user/.config/containers/storage.conf
containerStore:
number: 2
paused: 0
running: 1
stopped: 1
graphDriverName: overlay
graphOptions: {}
graphRoot: /var/home/user/.local/share/containers/storage
graphRootAllocated: 510389125120
graphRootUsed: 201430126592
graphStatus:
Backing Filesystem: btrfs
Native Overlay Diff: "true"
Supports d_type: "true"
Using metacopy: "false"
imageCopyTmpDir: /var/tmp
imageStore:
number: 104
runRoot: /run/user/1000/containers
volumePath: /var/home/user/.local/share/containers/storage/volumes
version:
APIVersion: 4.2.1
Built: 1662580699
BuiltTime: Thu Sep 8 03:58:19 2022
GitCommit: ""
GoVersion: go1.18.5
Os: linux
OsArch: linux/amd64
Version: 4.2.1
```

**Package info (e.g. output of `rpm -q podman` or `apt list podman` or `brew info podman`):**

```
podman-4.2.1-2.fc36.x86_64
```

**Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)**

- Latest: No
- Troubleshooting: Yes

**Additional environment details (AWS, VirtualBox, physical, etc.):**

Fedora Silverblue 36

Contributor guide

Open the contributing guide

Research direction

Start by tracing the toolbox run and distrobox enter command paths that use a Podman exec session, then compare the requested behavior with bubblewrap's bwrap --die-with-parent. Done means the optional behavior is clearly defined and implemented for the relevant command path, with coverage showing that the exec session terminates when its parent terminal process exits.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, linux
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.