gpt4 book ai didi

docker - Docker中的Subshel​​l命令

转载 作者:行者123 更新时间:2023-12-02 19:30:03 26 4
gpt4 key购买 nike

在构建过程中,我需要调用zipalign,它位于我正在使用的docker容器中的某个路径上:

$ docker run nathansamson/flutter-builder-docker:v0.7.3 find . -iname zipalign
./opt/android-sdk-linux/build-tools/28.0.1/zipalign

如果docker容器已更新并且有新的android sdk,则此路径可以更改。例如,这可能是将来的道路:
$ docker run nathansamson/flutter-builder-docker:v0.9.9 find . -iname zipalign
./opt/android-sdk-linux/build-tools/42.0.0/zipalign

因此,与其硬编码对
docker run nathansamson/flutter-builder-docker:v0.7.3 \
/opt/android-sdk-linux/build-tools/28.0.1/zipalign -h

我想要一个通用的解决方案,该解决方案可以自动找到zipalign的路径。我已经尝试过一个subshel​​l
$ docker run nathansamson/flutter-builder-docker:v0.7.3 $(find . -iname zipalign) -h
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec: \"-h\":
executable file not found in $PATH": unknown.
ERRO[0001] error waiting for container: context canceled

并为该文件夹添加通配符:
$ docker run nathansamson/flutter-builder-docker:v0.7.3 /opt/android-sdk-linux/build-tools/*/zipalign -h 
docker: Error response from daemon: OCI runtime create failed:
container_linux.go:348: starting container process caused "exec:
\"/opt/android-sdk-linux/build-tools/*/zipalign\": stat /opt/android-
sdk-linux/build-tools/*/zipalign: no such file or directory": unknown.
ERRO[0001] error waiting for container: context canceled

因此,子shell和通配符在Docker中不起作用。有什么想法可以在我每次打电话时找到zipalign的路径吗?

最佳答案

find可以使用-exec选项执行某些操作。

find . -name zipalign -exec bash -c '"$0"' {} \;

在您的示例中:
docker run nathansamson/flutter-builder-docker:v0.7.3 find . -name zipalign -exec bash -c '"$0"' {} \;

关于docker - Docker中的Subshel​​l命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52285400/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com