Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

365
Visualizações
How to manage environment variables in Rancher

I want manage environment variables in a stack, then the service can use it. For example: I definition a evn tracker_ip=192.168.0.101, then I want use it in service create.

create service

what should I do

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

There can be several answers depending on what you are trying to do and how you are deploying your stack.

Using the CLI / Rancher Compose

If you are using the command line, you can just use variable interpolation. Instructions on how to do so can be found in the official documentation:

https://docs.rancher.com/rancher/v1.5/en/cli/variable-interpolation/

Using the Rancher UI / Catalogs

If you want to do it through the Rancher UI, you can do it by creating a template in a catalog and having questions to input your environment variables. More details on how to do so here:

https://docs.rancher.com/rancher/v1.5/en/catalog/private-catalog/

You can define questions in the rancher-compose.yml file like this:

version: '2'
catalog:
  name: My Application
  version: v0.0.1
  questions:
  - variable: TRACKER_IP
    label: Tracker IP address
    required: true
    default: 192.168.0.101
    type: string

You can then push the answers to the environment section of your docker-compose.yml template for use within your image:

version: '2'
services:
  web:
    image: myimage
    ports:
    - 8000
    environment:
      TRACKER_IP: ${TRACKER_IP}
about 4 years ago · Santiago Trujillo Relatório

0

There is no way to do exactly what you're asking, because that would allow editing of the variables of running containers and containers are immutable. Environment variables can be defined on services but not defined once on stacks and made available to all services.

Secrets are somewhat like this and can be shared across services, but not edited.

about 4 years ago · Santiago Trujillo Relatório

0

Depending on where the tracker_ip is associated, you could also create an external service as part of the stack. The external service essentially just creates a DNS entry in Rancher. So you could then just link your service to the external_tracker service in compose and refer to tracker.

version: '2'
services:
  myservice:
    ...
    link:
      - tracker_service:tracker
...
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda