我在尝试创建一个公开Linux的Cloudflare's Tunnel可执行文件的docker镜像时遇到了麻烦。到目前为止,我已经完成了我的docker镜像的工作(镜像来自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"]
在official documentation for their kubernetes setup之后,我通过以下方式将其作为边车添加到了我的部署中:(此处
cloudflare-argo:5
是从上面的dockerfile构建的镜像) - 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
)。
关于docker - 试图弄清楚如何为Docker容器化此可执行文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62099573/