[Django]-Environ variables in .env file in Django and docker

2👍

You can put a command “copy” in your local Dockerfile, that copy your local .env file for use inside docker container.
As example:

FROM alpine:latest
RUN apk add --update \
nodejs \
nodejs-npm && rm -rf /var/cache/apk/*
COPY package.json /package.json
RUN npm i --silent --prod
#COPY .env /.env
COPY app.js /app.js
COPY bin/ /bin
COPY lib/ /lib
COPY server/ /server
COPY sql/ /sql
EXPOSE 3002
CMD ["npm","start"]

As you can see is just uncomment the line with “copy”command, to copy your local environment.

Leave a comment