Trying to figure out how to get this executable containerised for docker

5/30/2020

I am having rough time trying to create a docker image that exposes Cloudflare's Tunnel executable for linux. Thus far I got to this stage with my docker image for it (image comes from https://github.com/jakejarvis/docker-cloudflare-argo/blob/master/Dockerfile)

FROM ubuntu:18.04

LABEL maintainer="Jake Jarvis <jake@jarv.is>"

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

RUN wget -O cloudflared.tgz https://bin.equinox.io/c/VdrWdbjqyF/cloudflared-stable-linux-amd64.tgz \
  && tar -xzvf cloudflared.tgz \
  && rm cloudflared.tgz \
  && chmod +x cloudflared

ENTRYPOINT ["./cloudflared"]

And following official documentation for their kubernetes setup I added it to my deployment as a sidecar via: (here cloudflare-argo:5 is image built from dockerfile above)

    - name: cloudflare-argo
      image: my-registry/cloudflare-argo:5
      imagePullPolicy: Always
      command: ["cloudflared", "tunnel"]
      args:
        - --url=http://localhost:8080
        - --hostname=my-website
        - --origincert=/etc/cloudflared/cert.pem
        - --no-autoupdate
      volumeMounts:
        - mountPath: /etc/cloudflared
          name: cloudflare-argo-secret
          readOnly: true
      resources:
        requests:
          cpu: "50m"
        limits:
          cpu: "200m"
  volumes:
    - name: cloudflare-argo-secret
      secret:
        secretName: my-website.com

However once I deploy I get CrashLoopBackOff error on my pod with following kubectl describe output

Created container cloudflare-argo

Error: failed to start container "cloudflare-argo": Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"cloudflared\": executable file not found in $PATH": unknown

-- Ilja
cloudflare
docker
kubernetes

2 Answers

5/30/2020

In your Dockerfile move the cloudflared binary to /usr/local/bin folder instead of running it from current WORKDIR.

  && chmod +x cloudflared \
  && mv cloudflared /usr/local/bin

ENTRYPOINT ["cloudflared"]
-- hariK
Source: StackOverflow

5/30/2020

In the dockerfile it is ./cloudflared, so that would be:

      command:
        - ./cloudflared
        - tunnel
        - --url=http://localhost:8080
        - --hostname=my-website
        - --origincert=/etc/cloudflared/cert.pem
        - --no-autoupdate

(also there is no reason to use both command and args, just pick one, if you drop the first item then use args).

-- coderanger
Source: StackOverflow