I am trying to set some environment variable by a script. (Like it is explained here: https://stackoverflow.com/a/55922307)
Dockerfile
FROM container1:latest
WORKDIR /etc/test
RUN ["/bin/bash", "-c", ". env/environment.sh && command2 && command3"]
COPY entry.sh .
ENTRYPOINT ["/etc/test/entry.sh"]
entry.sh
#!/bin/bash
. /etc/test/env/environment.sh
exec "$@"
Then build the image:
docker build -t docker-test .
Then run it:
docker run -it -d --name env-test docker-test:latest
But the container stops after some seconds:
COMMAND CREATED STATUS
"/etc/test/entry.sh" 7 seconds ago Exited (0) 1 second ago
Why is the container not running anymore? I would like to go into it with docker exec. Can I somehow test if the environment variables are correctly set?
I was trying to add CMD [ "sh", "-c", "echo $PATH" ]
add the end, but nothing happens...