I use the AWS Lambda docker image to develop and do some test on my local host or during CI/CD.
On my Docker file I added ENV PYTHONPATH "${PYTHONPATH}:/var/task"
to bind /var/task
where my python libraries are installed.
I would to do the same but without add ENV PYTHONPATH "${PYTHONPATH}:/var/task"
in my Dockerfile.
I tried to add this line in my docker-compose but my python path wasn’t updated.
environment:
- PYTHONPATH="${PYTHONPATH}:/var/task"
What did I do wrong?
2
Answers
Example:
Note 1: Starting with +v1.28, .env file is placed at the base of the project directory.
Note 2: Ideally
.env
file will be in the same dir wheredocker-compose
at. But you can customize as per you need.$ docker-compose config
Follow https://stackoverflow.com/a/34600106/3098330
If you use
${VARIABLE}
syntax, Compose will do variable substitution.To prevent Compose interpolation, you can use the
$$
to escape$
see: https://docs.docker.com/compose/compose-file/compose-file-v3/#variable-substitution