You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.`FROM python:3.10` uses the `python:3.10` image as a base.
36
-
2.`WORKDIR /app` does it so everything we do in the Docker image will happen in the image's `/app` directory.
37
-
3.`RUN pip install flask` runs a command in the image. Here the command is `pip install flask`, which is what we need to run our app.
38
-
4.`COPY . .` is a bit cryptic! It copies everything in the current folder (so `app.py`) into the image's current folder (so `/app`).
39
-
5.`CMD ["flask", "run", "--host", "0.0.0.0"]` tells the image what command to run when you start a container. Here the command is `flask run --host=0.0.0.0`.
37
+
2.`EXPOSE 5000` is basically documentation[^1]. It tells the user of the Dockerfile that port 5000 is something the running container will use.
38
+
3.`WORKDIR /app` does it so everything we do in the Docker image will happen in the image's `/app` directory.
39
+
4.`RUN pip install flask` runs a command in the image. Here the command is `pip install flask`, which is what we need to run our app.
40
+
5.`COPY . .` is a bit cryptic! It copies everything in the current folder (so `app.py`) into the image's current folder (so `/app`).
41
+
6.`CMD ["flask", "run", "--host", "0.0.0.0"]` tells the image what command to run when you start a container. Here the command is `flask run --host=0.0.0.0`.
40
42
41
43
:::tip
42
44
We need `--host=0.0.0.0` to make Docker be able to do port forwarding, as otherwise the Flask app will only be accessible within the container, but not outside the container.
@@ -120,4 +122,6 @@ docker run -dp 5001:5000 rest-apis-flask-python
120
122
121
123
Try making requests using the URL `127.0.0.1:5000` with Insomnia REST Client or Postman, and you should see it working well!
122
124
123
-

125
+

0 commit comments