I have an Docker image and I can run it:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag
Then I can source a script in the following way:
root@86bfac2f6ccc:/# source entrypoint.sh
The script looks like that:
more entrypoint.sh
#!/bin/bash
. /env.sh
. /root/miniconda3/etc/profile.d/conda.sh
conda activate base
exec "$@"
Which activate the base env:
(base) root@86bfac2f6ccc:/#
So far so good but I don't managed to include this in the Dockerfile
or as parameters to docker run
:
I tried many things:
For example:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag source entrypoint.sh
/bin/bash: source: No such file or directory
But the script exist and can be executed:
docker run -it --entrypoint="/bin/ls" gcr.io/docker:tag -la
...
-rwxr-xr-x 1 root root 94 Apr 26 20:36 entrypoint.sh
...
Or:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag ". /entrypoint.sh"
/bin/bash: . /entrypoint.sh: No such file or directory
Or in the Docker file:
ENTRYPOINT ["source", "/entrypoint.sh"]
I guess the issue I have is maybe related the fact that source
evaluate a script in the current shell.
Any guidance to achieve what I want ? It seems quite obvious but I am out of idea.