Reputation: 103
I know this question would look silly.
But I am new to the Docker
and kinda ambiguous about how to write a proper Docker file
Docker file depends on what we are deploying on the container (PHP, nginx, node, etc.)
pulling an image is okay. But How do we exactly know what CMD
should be run and what PATH
should be given?
Some Dockerfiles don't need a CMD
part. Some need PATH
and some don't. How do we exaclt know this? Can we see this if we clicked on a tag
in docker hub? I can see there is a Dockerfile
for each tag. But that is a complex Dockerfile
How do we exactly know which syntaxes (i.e. PATH
, CMD
etc...) should write in the Dockerfile
to make the deployment work?
Upvotes: 0
Views: 3004
Reputation: 5612
most of this just come along with your knowledge and experience around the base image ecosystem.
Nevertheless, as @rahultyagi stated, search the documentation of your language for Dockerfile examples. most modern libs and frameworks come with an official Dockerfile you can refer to as your base image, and an example Dockerfile you can copy and tweak for your app.
a great tool ive recently run into is called hadolint
and its kind of a linter for your dockerfiles. it also got an online version you can try: https://hadolint.github.io/hadolint/
my final own tip is to make as much dummy dockerfiles as you can on your free time, for tools and libraries you run into, until you get the hang of it.
Cheers & Good Luck!
Upvotes: 2