2017-03-18 185 views
0

我有一個docker-compose文件,該文件在條目上執行bash腳本。在Docker bash腳本中運行時找不到命令

這個bash腳本刪除一些文件,然後嘗試printenv返回錯誤printenv: not found

現在,如果我在交互模式泊塢窗容器並執行它工作正常的printenv

在交互模式

docker run -it microsoft/aspnetcore-build /bin/sh

> printenv運行碼頭工人正常工作

在運行搬運工,組成

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腳本(二uild.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" 

多克爾 - 撰寫文件(泊塢窗 - 撰寫-build.yml)

version: '2' 
services: 
    aspnetapp-build: 
    image: microsoft/aspnetcore-build 
    volumes: 
     - ../.:/sln 
    working_dir: /sln 
    entrypoint: ["sh", "./ci/build.sh"] 

回答

1

您刪除bin目錄包含printenv。

這應該說明吧:

docker run -it --rm -w "/srv" microsoft/aspnetcore-build sh -c 'printenv; rm -rf ../**/bin; printenv'