dockerdockerfilegnupgttyapt-key

apt-key command works on shell but fails on Dockerfile


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


Solution

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

    Any idea however why this was happening?