I am a beginner in Docker. Based on my understanding, a dockerfile will usually end of with a CMD or ENTRYPOINT and the purpose is that a process will get executed when the container start. Example
# syntax=docker/dockerfile:1
FROM node:12-alpine
RUN apk add --no-cache python2 g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
Recently I came across some projects that uses docker-compose. The dockerfile does not have entrypoint or cmd. Instead the docker-compose file has definition for the command. Example:
https://docs.docker.com/samples/django/
My question is whether this type of dockerfile without cmd/entrypoint is only created for dockercompose? Is it also useable for deploying the docker image to kubernetes?
...this type of dockerfile without cmd/entrypoint is only created for dockercompose?
Nope.
Is it also useable for deploying the docker image to kubernetes?
Usable for K8s, example:
apiVersion: v1
kind: Pod
metadata:
name: busybox
spec:
containers:
- name: busybox
image: busybox
command: ["ash","-c","sleep 1d"] # <-- set your command
You can also set at the command line with docker run like: docker run --init -it --rm busybox ash -c "sleep 1d"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.