Failed to Establish an SSL Connection During a gcloud Build


What happend?

I faced this error when I executed the gcloud builds submit command, which is similar to docker build.

--2026-08-17 07:07:54--  https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz
Resolving johnvansickle.com (johnvansickle.com)... 107.180.57.212
Connecting to johnvansickle.com (johnvansickle.com)|107.180.57.212|:443... connected.
GnuTLS: Error in the pull function.
Unable to establish SSL connection.
The command '/bin/sh -c wget https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz &&     mkdir -p /opt/ffmpeg &&     tar xvf ffmpeg-release-amd64-static.tar.xz -C /opt/ffmpeg --strip-components=1 &&     rm ffmpeg-release-amd64-static.tar.xz &&     ln -s /opt/ffmpeg/ffmpeg /usr/local/bin/ffmpeg &&     ln -s /opt/ffmpeg/ffprobe /usr/local/bin/ffprobe' returned a non-zero code: 4
ERROR
ERROR: build step 0 "gcr.io/cloud-builders/gcb-internal" failed: step exited with non-zero status: 4

How to fix:

Use curl command instead of wget

I first tried using curl instead of wget.

RUN curl -fL \
    --retry 10 \
    --retry-delay 5 \
    --retry-all-errors \
    -o /tmp/ffmpeg.tar.xz \
    https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz && \
    mkdir -p /opt/ffmpeg && \
    tar xf /tmp/ffmpeg.tar.xz \
      -C /opt/ffmpeg \
      --strip-components=1 && \
    rm /tmp/ffmpeg.tar.xz && \
    ln -s /opt/ffmpeg/ffmpeg /usr/local/bin/ffmpeg && \
    ln -s /opt/ffmpeg/ffprobe /usr/local/bin/ffprobe

Change Base Image

I was using amazoncorretto:17 as the base image.

FROM amazoncorretto:17

Eventually, I changed my Dockerfile to use another base image.

FROM eclipse-temurin:17-jre-jammy

RUN apt-get update && \
    apt-get install -y --no-install-recommends ffmpeg && \
    rm -rf /var/lib/apt/lists/*

RUN ffmpeg -version && ffprobe -version

COPY /build/libs/backend.jar /app.jar

EXPOSE 8080

ENV JAVA_OPTS="-Duser.timezone=Asia/Tokyo"

ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app.jar"]

My previous base image, amazoncorretto:17, is based on Amazon Linux, so apt-get is not available. On the other hand, eclipse-temurin:17-jre-jammy is based on Ubuntu 22.04 (Jammy), which is a Debian-based Linux distribution. Therefore, I can use apt-get to install FFmpeg.

Finally, I was able to solve this problem.

Here are some things I learned today:

  • Docker base images can be based on different Linux distributions.
  • Different Linux distributions use different package managers.
  • For example, Ubuntu and Debian use apt, while Amazon Linux uses dnf or yum, depending on the version.
  • Choosing an appropriate base image can make it much easier to install system packages such as FFmpeg.

Just a Thought

Honestly, I don’t think I actually solved the SSL connection issue. It works now after changing the base image, but that doesn’t really explain why the SSL connection failed in the first place. So… if this happens again, I’m not really sure what I’ll do next.