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

Execution of scripts in containers #13

Closed
umarcor opened this issue Feb 17, 2021 · 4 comments
Closed

Execution of scripts in containers #13

umarcor opened this issue Feb 17, 2021 · 4 comments

Comments

@umarcor
Copy link
Contributor

umarcor commented Feb 17, 2021

I am trying to execute a test script inside the aarch64 container, which updates the system and clones a git repo.

set -e

cd $(dirname "$0")

echo '::group::Update'
pkg update
yes | apt upgrade
echo '::endgroup::'

pkg install -y git

ls -la

mkdir -p ghdl
cd ghdl

git clone https://github.com/ghdl/ghdl

By default, these containers' entrypoint is login. Hence, executing commands non-interactively requires overriding the entrypoint. This is the execution command I tried:

docker run \
  -v $(pwd):/data/data/com.termux/files/home/packages \
  -w /data/data/com.termux/files/home/packages \
  --entrypoint sh \
  xeffyr/termux:aarch64 \
  -c ./test.sh

The container is properly started, the system is updated and git is installed. However, mkdir fails with a permission denied error. Upon further inspection, ls -la shows that the bind directory is owned by user radio, instead of system.

See:

@ghost
Copy link

ghost commented Feb 17, 2021

Expected behavior, Docker volumes will not redefine the user id and by default container force-drops privileges to uid 1000 as Termux doesn't allow to use package manager as root and in general is not designed to work with superuser privs.

You can try to use uid 0 (root).

docker run -it -u 0 xeffyr/termux

@ghost ghost closed this as completed Feb 17, 2021
@umarcor
Copy link
Contributor Author

umarcor commented Feb 18, 2021

Thanks for the explanation. FTR, -u 0 does not work: https://github.com/umarcor/termux-docker/runs/1923711019?check_suite_focus=true#step:5:22. However, copying the sources to some other location inside the container is a possible workaround.

@ghost
Copy link

ghost commented Feb 18, 2021

@umarcor As I wrote, Termux does not allow use of package manager as root. This is not subject for fixing as intended behavior.

@umarcor
Copy link
Contributor Author

umarcor commented Feb 18, 2021

@xeffyr I think there was a misunderstanding. I was not suggesting you to use the workaround. I wrote it for the record, so that other users are aware that the following does work:

docker run \
  -v $(pwd):/data/data/com.termux/files/home/src \
  -w /data/data/com.termux/files/home \
  --entrypoint /data/data/com.termux/files/usr/bin/sh \
  xeffyr/termux:aarch64 \
  -c 'cp -r src work; ./work/test_script.sh'

Note the last line: cp -r src work.

https://github.com/hdl/Termux-packages/blob/feat/ci/.github/workflows/Test.yml#L52

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant