在Docker容器内以非交互方式解密gpg文件

时间:2017-08-30 11:47:12

标签: docker encryption gnupg

我正在尝试解密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但没有成功。

1 个答案:

答案 0 :(得分:0)

我刚刚发现了这个问题:

import csv
delimiter_type=';'
with open('file_name.csv', 'wb') as csvfile:
    spamwriter = csv.writer(csvfile, delimiter=delimiter_type,
                            quotechar='|', quoting=csv.QUOTE_MINIMAL)
    spamwriter.writerow(['Spam'] * 5 + ['Baked Beans'])
    spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])

即。应使用引号,以便将环境变量正确转换为文本。