如何以随机用户的身份在容器中运行github cli

问题描述

我已经设法在容器中安装了github cli,但是我无法以随机用户身份运行它(出于安全考虑,open shift确实以随机用户身份运行容器) 我应该预先创建/ chmod / chown哪个目录以使其起作用?

谢谢!

docker文件

RUN wget https://github.com/cli/cli/releases/download/v1.0.0/gh_1.0.0_linux_amd64.deb
RUN dpkg -i gh_*_linux_amd64.deb
RUN chmod g+rwx -R /usr/local/bin/gh  # <- not enough
RUN gh version

容器日志:

...
Step 7/28 : RUN gh version
 ---> Running in 09d1ffbfcc02
Welcome to GitHub CLI!

To authenticate,please run `gh auth login`.
You can also set the GITHUB_TOKEN environment variable,if preferred.
The command '/bin/sh -c gh version' returned a non-zero code: 4
`/` is not writable.
...

解决方法

docs中有一个错误,它是 echo '[' < data.json jq -nr --stream ' fromstream(1|truncate_stream(inputs)) | (if has ("middleName") then .sortableMiddleName=.middleName else . end | if has("middleName") then .middleName=[.middleName] else . end),","' | sed '$d' echo ']' gh --version

gh version在前面提到的命令之前也有帮助。