Skip to content
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

Quoted env variables maintain their quotes #167

Open
nmvrc opened this issue Jan 7, 2022 · 6 comments
Open

Quoted env variables maintain their quotes #167

nmvrc opened this issue Jan 7, 2022 · 6 comments

Comments

@nmvrc
Copy link

nmvrc commented Jan 7, 2022

When a container is being deployed and <container>.env contains a variable that is quoted, such as MDATA_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 /]#

@bahamat
Copy link
Member

bahamat commented Jan 8, 2022

What shell are you using with the docker client?

@nmvrc
Copy link
Author

nmvrc commented Jan 10, 2022

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"
$

@bahamat
Copy link
Member

bahamat commented Jan 10, 2022

In your "docker" example, what is the DOCKER_HOST?

@nmvrc
Copy link
Author

nmvrc commented Jan 10, 2022

It is unset:

$ echo $DOCKER_HOST

$

@bahamat
Copy link
Member

bahamat commented Jan 10, 2022

OK, so that one is a real linux host?

@nmvrc
Copy link
Author

nmvrc commented Jan 10, 2022

It is the Docker Desktop instance running locally on my system (MacOS).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants