New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bitnami/nats] environment variables are empty when using docker-compose.yml to deployment #66439
Comments
Hi @alexsunlee, I just tried to reproduce the issue but I couldn't do so. I made this change in the default docker-compose.yml file
and confirmed that the token was properly set in the container
|
Hi @jotamartos, elon@mask:~/work$ docker compose up -d nats
WARN[0000] The "NATS_DATA_DIR" variable is not set. Defaulting to a blank string.
WARN[0000] The "NATS_CONF_DIR" variable is not set. Defaulting to a blank string.
WARN[0000] The "NATS_CONF_DIR" variable is not set. Defaulting to a blank string.
WARN[0000] The "NATS_DATA_DIR" variable is not set. Defaulting to a blank string.
WARN[0000] The "NATS_CONF_DIR" variable is not set. Defaulting to a blank string.
WARN[0000] The "NATS_TOKEN" variable is not set. Defaulting to a blank string.
1 error(s) decoding:
* error decoding 'volumes[0]': invalid spec: /opt/dnsight/nats::rw: empty section between colons |
You have an error in the docker-compose.yml file and that's why the deployment fails
Please set the path to mount the volume as "NATS_DATA_DIR" is not available in your local machine. |
The full docker-compose.yaml services:
nats:
image: bitnami/nats:latest
container_name: dnsight-nats
restart: always
ports:
- '4222:4222'
- '6222:6222'
- '8222:8222'
environment:
- NATS_TOKEN=6DFVC5hthwVvd6c8rsbKPOouSdD9qh0kDggTghrV48XDb9Q4q1AkrXTrBWh3OL27
- NATS_CONF_FILE=${NATS_CONF_DIR}/nats.conf
- NATS_EXTRA_ARGS=-js -n=dnsight-nats -sd=${NATS_DATA_DIR} -c ${NATS_CONF_DIR}/nats.conf --auth ${NATS_TOKEN}
volumes:
- /opt/dnsight/nats:${NATS_DATA_DIR}:rw
- ./nats.conf:${NATS_CONF_DIR}/nats.conf
# networks:
# - dnsight-network the nats.conf
because the variables are empty, so, the errors are like this * error decoding 'volumes[0]': invalid spec: /opt/dnsight/nats::rw: empty section between colons |
You can't use env vars to specify the directory to copy the volume to. Please take a look at this section of the documentation if you want to mount a custom conf file https://github.com/bitnami/containers/tree/main/bitnami/nats#full-configuration |
I have updated my docker-compose.yml image: bitnami/nats:latest
container_name: dnsight-nats
restart: always
ports:
- '4222:4222'
- '6222:6222'
- '8222:8222'
environment:
- NATS_EXTRA_ARGS=-js -n=dnsight-nats -sd=${NATS_DATA_DIR} #-c ${NATS_CONF_DIR}/nats.conf
volumes:
# - /opt/dnsight/nats:${NATS_DATA_DIR}:rw
- ./nats.conf:/bitnami/nats/conf/nats.conf
networks:
- dnsight-network and successed to run docker, and I entered it. elon@mask:~/work$ docker exec -ti nats /bin/bash
I have no name!@7744e811ca49:/opt/bitnami/nats$ env
HOSTNAME=7744e811ca49
PWD=/opt/bitnami/nats
OS_FLAVOUR=debian-12
NATS_EXTRA_ARGS=-js -n=dnsight-nats -sd=
HOME=/
TERM=xterm
SHLVL=1
BITNAMI_APP_NAME=nats
APP_VERSION=2.10.14
OS_NAME=linux
PATH=/opt/bitnami/common/bin:/opt/bitnami/nats/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
OS_ARCH=amd64
_=/usr/bin/env my question is, where is
|
what I totally mean is, if I set environment in So, I think is the file /opt/bitnami/scripts/nats-env.sh is not working when I using
|
Hi @alexsunlee, You are mixing things up and that's why you think that the container doesn't work properly but that's not the case. Let me explain. The nats-env.sh script is loaded when executing different actions in the container, for example when starting the service The nats-env.sh script allows you edit the different env vars by providing then as environment variables when launching the container. The service will use your value instead of the default one we configure in the script. You see all env vars when executing the https://github.com/bitnami/containers/blob/main/bitnami/nats/2/debian-12/Dockerfile However, if you execute |
Name and Version
bitnami/nats:latest
What architecture are you using?
Linux x86_64 ubuntu
What steps will reproduce the bug?
When I run docker compose up -d for my nats container, I found all environment varibles are empty. Yaml example is as follow.
What is the expected behavior?
If I up this container my hand without any envirnment variables.
What do you see instead?
after up yaml, the command line's output as follow
All environments variables are empty, so, why?
Additional information
I was saw the document from README, environment variables have two type, one is writable variables, and another is read only, I think the read only one should not be replaced. The only reason I think is the file
/opt/bitnami/scripts/nats-env.sh
is not work.Thanks a lot for helping me to solving this problem.
The text was updated successfully, but these errors were encountered: