我有一个docker-compose文件,可以在输入时执行bash脚本。
此bash脚本删除了一些文件,然后尝试printenv
返回错误printenv: not found
现在,如果我以交互模式运行docker容器并执行printenv
它就可以了。
以交互模式运行泊坞窗
docker run -it microsoft/aspnetcore-build /bin/sh
> printenv
工作正常
在docker-compose中运行
docker-compose -f docker-compose-build.yml up
Starting ci_aspnetapp-build_1
Attaching to ci_aspnetapp-build_1
aspnetapp-build_1 | rm -rf ../**/bin -> Done
aspnetapp-build_1 | rm -rf ../**/obj -> Done
aspnetapp-build_1 | ./ci/build.sh: 8: ./ci/build.sh: printenv: not found
ci_aspnetapp-build_1 exited with code 127
Bash脚本(build.sh)
#!bin/bash
set -e
rm -rf ../**/bin
printf "rm -rf ../**/bin -> Done\n"
rm -rf ../**/obj
printf "rm -rf ../**/obj -> Done\n"
rm -rf ../**/publish/web
printenv
printf "rm -rf ../**/publish/web -> Done\n"
Docker-Compose文件(docker-compose-build.yml)
version: '2'
services:
aspnetapp-build:
image: microsoft/aspnetcore-build
volumes:
- ../.:/sln
working_dir: /sln
entrypoint: ["sh", "./ci/build.sh"]
答案 0 :(得分:1)
您正在删除包含printenv的bin
目录。
这应该说明一下:
docker run -it --rm -w "/srv" microsoft/aspnetcore-build sh -c 'printenv; rm -rf ../**/bin; printenv'