Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

371
Views
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

over 4 years ago · Santiago Trujillo
3 answers
Answer question

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}
over 4 years ago · Santiago Trujillo Report

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.

over 4 years ago · Santiago Trujillo Report

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
...
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!