Reputation: 1706
If I peek inside the image and ls in my directory, I see:
drwxr-xr-x 1 root root 4096 Dec 10 22:30 .
drwxr-xr-x 1 root root 4096 Dec 10 22:35 ..
-rw-r--r-- 1 root root 741 Dec 9 02:45 .env
I'm trying to CMD source .env && ./myapp
(myapp is a placeholder, I have a lot more files in here!) but for some reason I get an issue - .env file not found
.
What am I doing wrong?
Edit: Below works for me, but this also works - CMD . ./.env && ./myapp
Not sure why I can run cat .env
, but I can't run source .env
..
Upvotes: 4
Views: 5976
Reputation: 1330102
Try the exec form of CMD
:
CMD [ "sh", "-c", "source .env && ./myapp" ]
That way, with the shell form, it is the shell that is doing the sourcing and not docker.
Make sure WORKDIR
is set to the right folder first.
Upvotes: 4