Home > Software engineering >  Dockerfile without CMD or Entrypoint
Dockerfile without CMD or Entrypoint

Time:01-06

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?

CodePudding user response:

...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"

  •  Tags:  
  • Related