Dockerfile 不會從 gitlab 目錄復制檔案。下面是dockerfile,
FROM docker.elastic.co/logstash/logstash:7.16.3
USER root
RUN yum install -y curl dos2unix
COPY scripts/somefile.sh /src/app/
RUN dos2unix /src/app/somefile.sh
WORKDIR /src/app/
ENTRYPOINT ["/src/app/somefile.sh"]
專案樹如下所示,
C:.
├───.idea
│ └───codeStyles
├───deployment
│ ├───dev
└───scripts
│ ├───somefile.sh
下面是deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: demo-app
name: demo-app
namespace: --
spec:
replicas: 1
selector:
matchLabels:
app: demo-app
template:
metadata:
labels:
app: demo-app
spec:
containers:
- image: docker-image-described
name: demo-app
resources: ...
volumeMounts:
- name: some-secret
mountPath: /src/abc/secret
readOnly: true
securityContext:
privileged: true
restartPolicy: Always
volumes:
- name: very-secret
secret:
secretName: some-secret
Further, building the image using gitlab-ci file. And then creating a deployment using this image. Please help me understand what am I doing wrong as when I exec inside the running pod, I can't see the file in the defined destination location.
I don't get any errors, which I usually do if there is an error about wrong source location. I also did go through some more similar questions, so I already checked that the EOL is Unix.
Also, I would like to add some observations,
- I cannot create the directory as well with
RUN mkdir -p /src/app/scripts/This also runs without any error, just not reflected inside the pod.
uj5u.com熱心網友回復:
這可能是由于使用了舊的(錯誤的)docker 映像,因此不會反映更改或更新。
如果鏡像標簽不是“最新”,則如果鏡像已經存在,Kubernetes 不會拉取新的鏡像版本。通過拉取鏡像并使用 docker 在本地運行來驗證鏡像是否正確構建。使用不同的標簽來強制 kubernetes 拉取鏡像。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/456898.html
