DevOps Classroom notes 09/Oct/2024

Dockerfile (Containerization contd…)

  • CMD and ENTRYPOINT
    • When a docker container starts it executes
      • Whatever is present in entrypoint and what ever has been written in CMD will be arguments to ENTRYPOINT
      • If entrypoint is present but CMD is not present in Dockerfile then whatever is written in ENTRYPOINT will be executed
      • IF ENTRYPOINT is not found and ony CMD Exists then CMD will be executed
    • CMD can be overriten by passing arguments after image name in docker run command
    • IF We donot write entrypoint or CMD the base images entrypoint or CMD will be considered
  • Your container will be in running state as long as PID1 (ENTRYPOINT + CMD) is running
  • Ideally anything can go in CMD or entrypoint, But in practice we execute the commands that start our application and wait till the application is executing.
  • Typical startup commands
    • java:
      • spring boot: java -jar <jarfile path>
      • app server: if your app runs on some external server then take the base image of the app server and dont write CMD or ENTRYPOINT
    • react js/angular js/vue js
      • first option: npm run start or equivalent
      • best option is to create a html site and run in nginx
    • dotnet (asp.net core)
      • dotnet <dll path>
    • Python
      • flask python app.py or server based startup
      • django python app.py or server based startup
      • fastapi uvicorn main:app --host 0.0.0.0 ...

Other instructions

  • Refer Here for official docs for reference
  • WORKDIR
  • USER

Lets Build a image for Python fastapi

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a comment

Turn on JavaScript to leave a comment.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Social Media Icons Powered by Acurax Web Design Company
Exit mobile version
%%footer%%