[英]Decrypt gpg files non-interactively inside a Docker container
我正在尝试解密docker容器内的gpg
文件。 大致来说, Dockerfile
完成以下基本工作:
FROM myimage
RUN ...
...
COPY docker-entrypoint.sh /entrypoint
RUN chmod u+x /entrypoint
docker-entrypoint.sh
包含:
gpg --decrypt --passphrase=${PASSWORD} /path/to/encrypted/file > /path/to/unencrypted/file
...
exec "$@"
我正在做:
docker build -t "myimage" .
docker run -e PASSWORD -ti myimage
我得到:
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
usage: gpg [options] --decrypt [filename]
…作为错误。 密码环境var已正确传递,并且该命令在我的计算机上正确运行。
我尝试了gpg2
,但没有成功。
我刚刚发现了问题:
gpg --decrypt --passphrase="${PASSWORD}" \
/path/to/encrypted/file > /path/to/unencrypted/file
即应该使用引号,以便将环境变量正确地转换为文本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.