question 481 Application Delivery · easy
Check a Dockerfile's CMD
A Dockerfile review bot checks the argument of the CMD instruction (the text after CMD ). Exec form, a JSON array of strings, lets the program receive stop signals directly; shell form doesn't. Report what is wrong with the argument, or None when it is fine. (Docker itself can't run here; this checks Dockerfile text.)
Read and diagnose: this can't run in the browser, so you'll read real code and output and answer questions about it.
Function
cmd_problem(args); args is the text after CMD Returns
"use exec form" when the text isn't valid JSON; "CMD must be a list of strings" when it is JSON but not a non-empty list of strings; otherwise NoneExamples
callcmd_problem('["python", "-m", "market.server"]')returnsNone
callcmd_problem('python -m market.server')returns'use exec form'
callcmd_problem('["python", 8000]')returns'CMD must be a list of strings'