Env not loaded on docker run

So, i got this dockerfile:

`FROM node:20.11.0-alpine AS BUILD_IMAGE

WORKDIR /strapi

Resolve node_modules

COPY package.json package-lock.json* ./
RUN npm ci --production=true --frozen-lockfile

Copy all for build and release cache if package.json update

COPY . .

ENV NODE_ENV=production

RUN npm run build

#------------------------------------------------------------------------------------

Create new namespace for final Docker Image

FROM node:20.11.0-alpine

Only copy source code without system file

COPY --from=BUILD_IMAGE /strapi /strapi

WORKDIR /strapi

EXPOSE 1337

ENV NODE_ENV=production
ENV STRAPI_LOG_LEVEL=debug

CMD [“npm”, “start”]
`

and run it with:
docker run -e ENV_PATH=/Users/alfinamegasiwi/Documents/MANSEK/STRAP-I/strapi-platform/.env strapi

why my .env doesnt get loaded? it shows this error:
error: “Bucket name” is required!
Error: “Bucket name” is required!
or postgresql error

This topic has been created from a Discord post (1284485524463157380) to give it more visibility.
It will be on Read-Only mode here.
Join the conversation on Discord

Env not loaded on docker

Hello!
Do you happen to have a .dockerignore file in your project that would ignore the .env file?
You can also try to directly load the env file with docker into proper environment variables like this:

docker run --env-file .env strapi

hello florent… thank you for your answer!

sadly, i don’t have .dockerignore file at my project

Does it work with docker run --env-file .env strapi?

it gives me this:
[2024-09-18 23:44:02.112] debug: ⛔️ Server wasn't able to start properly. [2024-09-18 23:44:02.114] error: AggregateError npm notice npm notice New minor version of npm available! 10.2.4 -> 10.8.3 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.8.3> npm notice Run npm install -g npm@10.8.3to update! npm notice

hello, thank you for your help. my error above because of my postgre connection, now it is safely running!