apt-key command works on shell but fails on Dockerfile
Asked Answered
D

1

13

The following command seems to work when running it in a shell

apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 \
            --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF 

but fails when executed in a Dockerfile as follows:

Warning: apt-key output should not be parsed (stdout is not a terminal)
Executing: /tmp/apt-key-gpghome.1CIuj3LUOP/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
gpg: cannot open '/dev/tty': No such device or address

The specific RUN command is executed in a openjdk:8 image which in turn draws from buildpack-deps:stretch-scm

Dithyramb answered 19/11, 2018 at 9:27 Comment(0)
D
18

Solved by adding --no-tty on the apt-key adv command.

Any idea however why this was happening?

Dithyramb answered 19/11, 2018 at 10:39 Comment(3)
I think this might be related to this: github.com/docker-library/postgres/issues/526Flashgun
I believe they fixed it also with the --batch option github.com/nodejs/docker-node/issues/922Signalman
I recently stumbled across the a similar issue (only with a different error message) and had to ressort to a combination of --no-tty and --batch to make it work.Trash

© 2022 - 2025 — McMap. All rights reserved.