D
D
DollyPapper2021-07-31 15:01:41
Docker
DollyPapper, 2021-07-31 15:01:41

docker-compose specifying env for dockerfile?

Good afternoon! Perhaps I'm dumb, but I can't figure out how to specify the environment variables that are described in .env during assembly to compose? There is the following Dockerfile building postgres:

FROM postgres:11
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo $TZ > /etc/timezone
RUN localedef -i ru_RU -c -f UTF-8 -A /usr/share/locale/locale.alias ru_RU.UTF-8
COPY ./setup.sh /docker-entrypoint-initdb.d/init-user-db.sh


As you can see, there is a TZ variable. When building via docker-compose build, no symlink is created because the variable is not declared. Although it is in .env
Do I need to somehow specifically specify this .env file to compose when building? I didn't find it in the docs for some reason.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Kuts, 2021-07-31
@fox_12

Looked bad:

version: '3.1'

services:

   someservice:
       env_file: .env
       ...

M
Max, 2021-08-01
@mbelskiy

docker builddoes not involve transmission of ENV from outside. Use --build-arg / ARG https://docs.docker.com/engine/reference/commandli...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question