0

I have a docker-compose file that executes a bash script on entry.

This bash script removes a few files, and then attempts to printenv which returns the error printenv: not found

Now if I run the docker container in interactive mode and execute the printenv it works fine.

Running docker in interactive mode

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

> printenv works fine

Running in 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 Script (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 File (docker-compose-build.yml)

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

1 Answer 1

1

You are deleting the bin dir that contains printenv.

This should illustrate it:

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.