shantanuo
shantanuo

Reputation: 32346

Using variables in config file

I have this dockerfile that is working correctly.

https://github.com/shantanuo/docker/blob/master/packetbeat-docker/Dockerfile

The only problem is that when my host changes, I need to modify packetbeat.yml file

  hosts: ["https://944fe807b7525eaf163f502e08a412c5.us-east-1.aws.found.io:9243"]
  password: "rzmYYJUdHVaglRejr8XqjIX7"

Is there any way to simplify this change? Can I use environment variable to replace these 2 values?

Upvotes: 0

Views: 59

Answers (1)

jonhid
jonhid

Reputation: 2135

Set environment variables in your docker container first. You can either set them by accessing your container

docker exec -it CONTAINER_NAME /bin/bash

HOST="https://944fe807b7525eaf163f502e08a412c5.us-east-1.aws.found.io:9243"
PASS="rzmYYJUdHVaglRejr8XqjIX7"

Or in your Dockerfile

ENV HOST https://944fe807b7525eaf163f502e08a412c5.us-east-1.aws.found.io:9243
ENV PASS rzmYYJUdHVaglRejr8XqjIX7

And the in the packetbeat.yml

 hosts: ['${HOST}']
 password: '${PASS}'

Upvotes: 2

Related Questions