Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --preserve-fds to podman run #6458

Closed
eriksjolund opened this issue Jun 1, 2020 · 7 comments · Fixed by #6625
Closed

Add support for --preserve-fds to podman run #6458

eriksjolund opened this issue Jun 1, 2020 · 7 comments · Fixed by #6625
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@eriksjolund
Copy link
Contributor

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

/kind feature

Description
Summary: Add support for --preserve-fds=N to podman run, in the same way that the command-line option is supported in podman exec.

Example:
The command foobar (in the container localhost/example) reads input from the file descriptor 0 and the file descriptor 3.
My goal is is to run foobar and pass the file file1.txt as file descriptor 0 and the file file2.txt as file descriptor 3. (Both file1.txt and file2.txt are located on the host system)

It would be nice to be able to run

$ cat file1.txt | podman run --rm -i --preserve-fds=1 localhost/example foobar 3< file2.txt

but that is currently not possible. Instead I need to use podman exec, something like this:

$ ctr=$(podman run -d --rm localhost/example sleep 300)
$ cat file1.txt | podman exec -i --preserve-fds=1 $ctr foobar 3< file2.txt

More info:

$ echo $0
-bash
$ podman --version
podman version 1.9.2
@openshift-ci-robot openshift-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Jun 1, 2020
@mheon
Copy link
Member

mheon commented Jun 1, 2020

Shouldn't be that difficult (the reason --preserve-fds is exec-only is that the original request was only for exec, there are no technical reasons it won't work with podman run). Unfortunately, most of the team is swamped with Podman 2.0 work at the moment, so I can't guarantee we'll get to this quickly; community PRs are always welcome, though!

@rhatdan rhatdan added the Good First Issue This issue would be a good issue for a first time contributor to undertake. label Jun 2, 2020
@rhatdan
Copy link
Member

rhatdan commented Jun 2, 2020

@eriksjolund Feel like opening a PR?
@sujil02 @QiWang19 PTAL

@eriksjolund
Copy link
Contributor Author

@rhatdan Up till now I've only been a Golang code reader and not a Golang code writer, so it would take a bit of an effort to do an PR. Unfortunately I have too little time right now.

@rhatdan
Copy link
Member

rhatdan commented Jun 3, 2020

No problem @eriksjolund, thanks for the issue.

I am always trying to encourage contributions. Anyone helping in OpenSource projects are appreciated.

eriksjolund added a commit to eriksjolund/simd-diagonal-load-json-demo that referenced this issue Jun 3, 2020
Just trying out an approach. This is not so important.

When libpod Github issue [Add support for --preserve-fds to podman run](containers/podman#6458)
has been implemented, maybe it makes some sense to let the command `demo` read the
options-input on file decriptor 3 instead of from a specified file path.

Signed-off-by: Erik Sjölund <[email protected]>
@QiWang19 QiWang19 self-assigned this Jun 8, 2020
@QiWang19
Copy link
Contributor

@eriksjolund can you provide more details? what the uses case foobar command specifically running?

QiWang19 added a commit to QiWang19/podman that referenced this issue Jun 19, 2020
Add --preservefds to podman run. close containers#6458

Signed-off-by: Qi Wang <[email protected]>
@eriksjolund
Copy link
Contributor Author

@eriksjolund can you provide more details? what the uses case foobar command specifically running?

I wanted to create a command-line tool to demonstrate a C++ library. The command-line tool needs two input files.
I think a user without much experience of bind mounts and SELINUX security file contexts would find it convenient to be able to do:

cat file1.txt | podman run --rm -i --preserve-fds=1 localhost/example foobar 3< file2.txt

I see that the PR #6625 has been merged:
Thanks!

Is the feature available in any release?

Fedora 32

[erik@laptop ~]$ cat /etc/fedora-release 
Fedora release 32 (Thirty Two)
[erik@laptop ~]$ podman --version
podman version 2.0.2
[erik@laptop ~]$ podman run --help | grep preserve-fds
[erik@laptop ~]$ 

Centos 8

[erik@centos ~]$ cat /etc/centos-release
CentOS Linux release 8.2.2004 (Core) 
[erik@centos ~]$ podman --version
podman version 2.0.3
[erik@centos ~]$ podman run --help | grep preserve-fds
[erik@centos ~]$ rpm -qi podman
Name        : podman
Epoch       : 0
Version     : 2.0.3
Release     : 1.el8
Architecture: x86_64
Install Date: Thu 23 Jul 2020 11:56:28 PM CEST
Group       : Unspecified
Size        : 74267642
License     : ASL 2.0
Signature   : RSA/SHA256, Thu 23 Jul 2020 09:42:24 PM CEST, Key ID 4d64390375060aa4
Source RPM  : podman-2.0.3-1.el8.src.rpm
Build Date  : Thu 23 Jul 2020 09:41:48 PM CEST
Build Host  : cloud107
Relocations : (not relocatable)
Vendor      : obs://build.opensuse.org/devel:kubic
URL         : https://podman.io/
Summary     : Manage Pods, Containers and Container Images
Description :
podman (Pod Manager) is a fully featured container engine that is a simple
daemonless tool.  podman provides a Docker-CLI comparable command line that
eases the transition from other container engines and allows the management of
pods, containers and images.  Simply put: alias docker=podman.
Most podman commands can be run as a regular user, without requiring
additional privileges.

podman uses Buildah(1) internally to create container images.
Both tools share image (not container) storage, hence each can use or
manipulate images (but not containers) created by the other.

Manage Pods, Containers and Container Images
podman is a simple management tool for pods, containers and images
[erik@centos ~]$ 

@eriksjolund
Copy link
Contributor Author

eriksjolund commented Jul 25, 2020

podman run --preserve-fds might become available in v2.1.0 according to
#6909 (comment)

@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 23, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/feature Categorizes issue or PR as related to a new feature. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants