BretFisher / php-docker-good-defaults

*WORK IN PROGRESS* sample PHP/Laravel app for Docker examples
MIT License
361 stars 117 forks source link

NGINX_GPGKEY error when trying to build base image #11

Open oragame opened 5 years ago

oragame commented 5 years ago

Hello, I am trying to build the base image from the base-php-nginx.Dockerfile with the following command:

docker build -f base-php-nginx.Dockerfile -t base-php-nginx:0.1 .

I am running into an error with the GPG KEY for Nginx, hoping thereis a simple solution. I have searched for an updated GPG key, but i keep finding the same one. I am guessing the key has been changed, and I just need an updated key to continue?

Here is the error output:

Step 7/16 : RUN NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; found=''; for server in ha.pool.sks-keyservers.net hkp://keyserver.ubuntu.com:80 hkp://p80.pool.sks-keyservers.net:80 pgp.mit.edu ; do echo "Fetching GPG key $NGINX_GPGKEY from $server"; apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; done; test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y nginx=${NGINX_VERSION} nginx-module-xslt=${NGINX_VERSION} nginx-module-geoip=${NGINX_VERSION} nginx-module-image-filter=${NGINX_VERSION} nginx-module-njs=${NJS_VERSION} gettext-base && rm -rf /var/lib/apt/lists/* ---> Running in 6d6fe2799f28 Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from ha.pool.sks-keyservers.net Warning: apt-key output should not be parsed (stdout is not a terminal) Executing: /tmp/apt-key-gpghome.o598SJLDOH/gpg.1.sh --keyserver ha.pool.sks-keyservers.net --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 gpg: keyserver receive failed: Cannot assign requested address Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from hkp://keyserver.ubuntu.com:80 Warning: apt-key output should not be parsed (stdout is not a terminal) Executing: /tmp/apt-key-gpghome.LMNYWg28ca/gpg.1.sh --keyserver hkp://keyserver.ubuntu.com:80 --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 gpg: cannot open '/dev/tty': No such device or address Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from hkp://p80.pool.sks-keyservers.net:80 Warning: apt-key output should not be parsed (stdout is not a terminal) Executing: /tmp/apt-key-gpghome.AoKzfhaAsr/gpg.1.sh --keyserver hkp://p80.pool.sks-keyservers.net:80 --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 gpg: cannot open '/dev/tty': No such device or address Fetching GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 from pgp.mit.edu Warning: apt-key output should not be parsed (stdout is not a terminal) Executing: /tmp/apt-key-gpghome.JHLtjLfkCd/gpg.1.sh --keyserver pgp.mit.edu --keyserver-options timeout=10 --recv-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 gpg: cannot open '/dev/tty': No such device or address error: failed to fetch GPG key 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 The command '/bin/sh -c NGINX_GPGKEY=573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62; found=''; for server in ha.pool.sks-keyservers.net hkp://keyserver.ubuntu.com:80 hkp://p80.pool.sks-keyservers.net:80 pgp.mit.edu ; do echo "Fetching GPG key $NGINX_GPGKEY from $server"; apt-key adv --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; done; test -z "$found" && echo >&2 "error: failed to fetch GPG key $NGINX_GPGKEY" && exit 1; echo "deb http://nginx.org/packages/debian/ stretch nginx" >> /etc/apt/sources.list.d/nginx.list && apt-get update && apt-get install --no-install-recommends --no-install-suggests -y nginx=${NGINX_VERSION} nginx-module-xslt=${NGINX_VERSION} nginx-module-geoip=${NGINX_VERSION} nginx-module-image-filter=${NGINX_VERSION} nginx-module-njs=${NJS_VERSION} gettext-base && rm -rf /var/lib/apt/lists/*' returned a non-zero code: 1

BretFisher commented 5 years ago

I get the nginx install info from the official image. Did you try updating the Dockerfile from there?

oragame commented 5 years ago

Thanks for getting back to me, Bret. I gave it a shot and had no luck, still having the GPG KEY issue. I tried updating the ENV for the version as well as copying and pasting bits of the RUN command, and then tried the entire RUN command. It all fails at the same place for me.

I'm probably not doing something right as I am still very new to the Dockerfiles (docker in general). But I want to say thank you for all of the help so far! I attended dockercon 2018 and got a lot from your session there, and have continued learning from your Udemy courses since then.

What I have switched to is laradock for now, I have been using it for development for about a year. I have been able to get a good start on a stack from that, and the stuff I learned in "Docker Swarm Mastery". I just really was hoping to get something more streamlined for dev/prod, and merging PHP with NGINX I know would save a lot of headache.

I'll keep working at it and report back if I discover anything helpful.

Thanks!

oragame commented 5 years ago

I had to add "--no-tty" to all gpg commands to get the build to complete successfully.

The error that led to this solution was: gpg: cannot open '/dev/tty': No such device or address

NGINX (line 75): apt-key adv --no-tty --keyserver "$server" --keyserver-options timeout=10 --recv-keys "$NGINX_GPGKEY" && found=yes && break; \

NODE (Lines 129-131): gpg --no-tty --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$key" || \ gpg --no-tty --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$key" || \ gpg --no-tty --keyserver hkp://pgp.mit.edu:80 --recv-keys "$key" ; \

Line 138: && gpg --no-tty --batch --decrypt --output SHASUMS256.txt SHASUMS256.txt.asc \

PCoetzeeDev commented 5 years ago

Thanks @oragame , I had exactly the same problem on this step. Your solution worked perfectly.