2017-08-30 64 views
0

我試圖解密Docker容器內的gpg文件。粗略地說了Dockerfile做基本的東西:在Docker容器內非交互式解密gpg文件

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 "[email protected]" 

我做:

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沒有成功。

回答

0

我剛剛發現的問題:

gpg --decrypt --passphrase="${PASSWORD}" \ 
    /path/to/encrypted/file > /path/to/unencrypted/file 

即報價應該按順序使用環境變量進行適當轉換爲文本。