Open nmvrc opened 2 years ago
What shell are you using with the docker client?
I'm using bash
. In the following output I am using the same portal.env
file from my previous comment but not using custom images.
Here is the compose file:
version: "3.9"
# version: "2.0" # uncomment for Triton
services:
foo:
image: tomcat:9
container_name: foo
ports:
- "8080:8080"
env_file:
- portal.env
# network_mode: bridge # uncomment for Triton
Here is the output from Docker:
$ docker-compose -f foo.yml up -d
[+] Running 2/2
⠿ Network docker_default Created 0.1s
⠿ Container foo Started 0.7s
$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
121a4d49bf64 tomcat:9 "catalina.sh run" 4 seconds ago Up 3 seconds 0.0.0.0:8080->8080/tcp foo
$ docker exec -it foo bash -c 'echo $MDATA_DB_URL'
//db:5432/dbname
$
Here is the output from triton-docker
(note: trying to echo
the variable in exec
does not work for some reason):
$ triton-compose -f foo.yml up -d
Creating foo
$ triton-docker --tls ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
717f07c9acaa tomcat:9 "catalina.sh run" 50 seconds ago Up 38 seconds 0.0.0.0:8080->8080/tcp foo
$ triton-docker --tls exec -it foo bash -c 'echo $MDATA_DB_URL'
$ triton-docker --tls exec -it foo bash
root@717f07c9acaa:/usr/local/tomcat# echo $MDATA_DB_URL
"//db:5432/dbname"
root@717f07c9acaa:/usr/local/tomcat#
Interestingly, running docker
instead of docker-compose
produces the same problems as triton-compose
:
$ docker run --name foo -d --env-file ./portal.env tomcat:9
1a3802a499aefc19fac524e33232c2093d2e66e1dc6056548a05f656a3c37249
$ docker exec -it foo bash -c 'echo $MDATA_DB_URL'
"//db:5432/dbname"
$
In your "docker" example, what is the DOCKER_HOST?
It is unset:
$ echo $DOCKER_HOST
$
OK, so that one is a real linux host?
It is the Docker Desktop instance running locally on my system (MacOS).
When a container is being deployed and
<container>.env
contains a variable that is quoted, such asMDATA_DB_URL="//db:5432/dbname"
, the value of the variable in the container contains the quotes.Example: portal.env:
MDATA_DB_URL="//db:5432/dbname"
Container variable value:
[root@12331e122a10 /]# echo $MDATA_DB_URL
"//db:5432/dbname"
[root@12331e122a10 /]#