Dockerfile does not copy file from gitlab directory. Below is the 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"]
The Project tree looks like the following,
C:.
├───.idea
│ └───codeStyles
├───deployment
│ ├───dev
└───scripts
│ ├───somefile.sh
below is 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.
CodePudding user response:
This is probably due to using an old (wrong) docker image, so changes or updates are not reflected.
Kubernetes does not pull a new image version if the image is already present if the image tag is not "latest". Verify that the image is correctly build by pulling it and running it locally with docker. Use a different tag to force kubernetes to pull the image.