Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

382
Vistas
Use multiple environment variables in docker compose path

I have the following compose file:

services:
  myproject:
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ASPNETCORE_HTTPS_PORT=44308
      - PROJECT_NAME=MyProject
    volumes:
      - ${APPDATA}/ASP.NET/Https:/root/.aspnet/https:ro
      - ${APPDATA}/Microsoft/UserSecrets:/root/.microsoft/usersecrets:ro
      - ${APPDATA}/Turma/${PROJECT_NAME}/Logs:/var/logs/${PROJECT_NAME}

On the line:

      - ${APPDATA}/Turma/${PROJECT_NAME}/Logs:/var/logs/${PROJECT_NAME}

It recognises ${APPDATA} but for ${PROJECT_NAME} it uses the literal string not the environment variable value.

Is there a way to make this work so the actual project name is used in path?

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

As far as I am aware, you cannot reference your env variables defined within the compose file later in the same compose file and have them interpreted. Your definition of $APPDATA works since that's set in the host's environment, not the compose file.

I tested both using the env variable and a .env file with compose 2.3 and 3, and neither worked.

I recommend wrapping your compose file in a run script where you can set the variables needed in your host shell, so you can have those interpreted properly. If you're deploying with a standard tool such as ansible, jenkins, etc. those can all set variables for you. This can look like the following:

#!/bin/bash
export PROJECT_NAME=foo
docker-compose up -d
unset PROJECT_NAME

Although it may not work for creating volumes, if you just need the variable to do something during the container's runtime (such as setting another environment variable), that can be put into an entrypoint script as well.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda