试图弄清楚如何为 docker 将此可执行文件容器化
Trying to figure out how to get this executable containerised for docker
我在尝试创建一个暴露 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)
的 docker 图像时遇到了困难
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"]
在 official documentation for their kubernetes setup 之后,我通过以下方式将其作为 sidecar 添加到我的部署中:(这里 cloudflare-argo:5
是根据上面的 docker 文件构建的图像)
- 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
然而,一旦我部署,我的 pod 就会出现 CrashLoopBackOff
错误,并出现以下 kubectl describe
输出
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
在 dockerfile 中它是 ./cloudflared
,所以那将是:
command:
- ./cloudflared
- tunnel
- --url=http://localhost:8080
- --hostname=my-website
- --origincert=/etc/cloudflared/cert.pem
- --no-autoupdate
(也没有理由同时使用command
和args
,只选择一个,如果你放弃第一个项目然后使用args
)。
在您的 Dockerfile 中,将 cloudflared 二进制文件从当前 WORKDIR
.
移动到 /usr/local/bin
文件夹而不是 运行
&& chmod +x cloudflared \
&& mv cloudflared /usr/local/bin
ENTRYPOINT ["cloudflared"]
我在尝试创建一个暴露 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)
的 docker 图像时遇到了困难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"]
在 official documentation for their kubernetes setup 之后,我通过以下方式将其作为 sidecar 添加到我的部署中:(这里 cloudflare-argo:5
是根据上面的 docker 文件构建的图像)
- 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
然而,一旦我部署,我的 pod 就会出现 CrashLoopBackOff
错误,并出现以下 kubectl describe
输出
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
在 dockerfile 中它是 ./cloudflared
,所以那将是:
command:
- ./cloudflared
- tunnel
- --url=http://localhost:8080
- --hostname=my-website
- --origincert=/etc/cloudflared/cert.pem
- --no-autoupdate
(也没有理由同时使用command
和args
,只选择一个,如果你放弃第一个项目然后使用args
)。
在您的 Dockerfile 中,将 cloudflared 二进制文件从当前 WORKDIR
.
/usr/local/bin
文件夹而不是 运行
&& chmod +x cloudflared \
&& mv cloudflared /usr/local/bin
ENTRYPOINT ["cloudflared"]