I have variable in.env EMAIL=mail@mail.com
My docker-compose.yml look:
services:
web:
container_name: ${NAME}}
environment:
EMAIL: ${EMAIL}
build: "."
ports:
- 3011:3000
stdin_open: true
tty: true
volumes:
- "./app:/src/app"
I want use EMAIL var in dockerfile, in command:
RUN ssh-keygen -q -t rsa -N "EMAIL" -f ~/.ssh/id_rsa
How look like this command? "${EMAIL}"?
For this you should use build args :
# docker-compose.yml
services:
web:
build:
context: "."
args:
EMAIL: ${EMAIL}
# ...
# Dockerfile
# ...
ARG EMAIL
RUN ssh-keygen -q -t rsa -N "${EMAIL}" -f ~/.ssh/id_rsa
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.