DEV Community

Discussion on: Create a Restful API with Golang from scratch

Collapse
 
dryluigi profile image
Mario Prasetya M. • Edited

hey i really love your article. how you explain is kinda concise and clear :). but the dockerfile section attract my attention. if you wouldn't mind, may I ask you a question? how the container is supposed to run when you only define ENTRYPOINT without CMD or other command related to running the built go application?

Collapse
 
pacheco profile image
Thiago Pacheco

Hi @dryluigi, thanks for the feedback!
The command to run is defined in the ENTRYPOINT line.
In the dockerfile we can specify how to run the app through either of these 2 options: CMD or ENTRYPOINT.
The ENTRYPOINT one is prefered if you have an specific built entrypoint to run the app, which in our case we have the air to run on dev mode and the todo built file if we want to run a production version. This option is good for apps that generate a build file, like Golang or Java apps for example.
The CMD is used when you want to define a default command that can be overridden or extended by whoever wants to use this file. In Node.js applications for example you might have a: CMD ['npm', 'start'].