Gpg在列出密钥时挂起(Docker安装)

huangapple go评论51阅读模式
英文:

Gpg hangs when listing keys (docker install)

问题

我尝试设置一个Docker镜像来打包和加密文件。

我的问题是,当我尝试在Dockerfile中执行时,当我运行 gpg --list-keys 时,shell会挂起,什么都不会发生。

没有错误消息。我在日志中也没有看到任何信息。

我的Dockerfile:

FROM alpine:3
COPY public.asc /
RUN apk add --no-cache gnupg openssh && ssh-keygen -A && mkdir /root/.ssh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 22/tcp
COPY entrypoint.sh /
RUN gpg --import /public.asc

如果我删除 RUN gpg --import /public.asc 并直接在连接到容器的shell中运行它,然后运行 gpg --list-keys,它能正常工作并返回密钥。

也许我在Docker构建镜像方面漏掉了一些东西?

英文:

I try to setup a docker image to tar and encrypt files.

My problem is when I try to do it with a Dockerfile, when I gpg --list-keys, shell hangs and nothing happens.

There is no error message. I see nothing in logs.

My Dockerfile :

FROM alpine:3
COPY public.asc /
RUN apk add --no-cache gnupg openssh && ssh-keygen -A && mkdir /root/.ssh
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 22/tcp
COPY entrypoint.sh /
RUN gpg --import /public.asc

If I delete the RUN gpg --import /public.asc and run it directly into a shell attached to the container and then gpg --list-keys, it's working fine and returning the key.

Maybe I'm missing something on how Docker is building the image ?

答案1

得分: 2

移除锁定文件解决了问题。

我的Dockerfile中的片段

密钥导入

RUN gpg --batch --import path_to_key.pub

移除锁定文件

RUN rm -f /home/my_user/.gnupg/public-keys.d/pubring.db.lock

在每次密钥导入后,您可能需要移除锁定文件。

英文:

Removing the lock file did the trick.

Snippet from my Dockerfile

Key Import

RUN gpg --batch --import path_to_key.pub

Removing the lock file

RUN rm -f /home/my_user/.gnupg/public-keys.d/pubring.db.lock

After each key import, you might have to remove the lock file.

huangapple
  • 本文由 发表于 2023年7月11日 05:10:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/76657359.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定