build: use exec form for flask example

shell form doesnt trap sigint

Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
This commit is contained in:
David Karlsson 2024-02-01 16:41:00 +01:00
parent 983368516f
commit 9b6bc8cd46
1 changed files with 13 additions and 3 deletions

View File

@ -92,7 +92,7 @@ COPY hello.py /
# final configuration
ENV FLASK_APP=hello
EXPOSE 8000
CMD flask run --host 0.0.0.0 --port 8000
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
```
Here's a breakdown of what this Dockerfile does:
@ -234,12 +234,22 @@ team members understand what this application is doing.
Finally, [`CMD` instruction](../../engine/reference/builder.md#cmd) sets the
command that is run when the user starts a container based on this image.
```dockerfile
CMD ["flask", "run", "--host", "0.0.0.0", "--port", "8000"]
```
This command starts the flask development server listening on all addresses
on port `8000`. The example here uses the "exec form" version of `CMD`.
It's also possible to use the "shell form":
```dockerfile
CMD flask run --host 0.0.0.0 --port 8000
```
In this case we'll start the flask development server listening on all addresses
on port `8000`.
There are subtle differences between these two versions,
for example in how they trap signals like `SIGTERM` and `SIGKILL`.
For more information about these differences, see
[Shell and exec form](../../engine/reference/builder.md#shell-and-exec-form)
## Building