user2366975
user2366975

Reputation: 4720

docker swam - secrets from file not resolving tilde

Using secrets from docker-compose on my dev machine works. But the remote server via ssh just says open /home/johndoe/~/my-secrets/jenkinsuser.txt: no such file or directory.

secret definition in stack.yml:

secrets:
  jenkinsuser:
    file: ~/my-secrets/jenkinsuser.txt

Run with: docker stack deploy -c stack.yml mystack

The documentation does not mention any gotchas about ~ path. I am not going to put the secret files inside . as all examples do, because that directory is version controlled. Am I missing some basics about variable expansion, or differences between docker-compose and docker swarm?

Upvotes: 0

Views: 321

Answers (1)

Xavier Brassoud
Xavier Brassoud

Reputation: 715

Your ~ character in your path is considered as literal. Use $HOME wich is treated as a variable in your string path.

Tilde character work only if it is unquoted. In your remote environment, the SWARM yaml parser consider your path as a string, where the prefix-tilde is read as a normal character (see prefix-tilde).

Upvotes: 1

Related Questions