<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://pzwiki.wdka.nl/mw-mediadesign/index.php?action=history&amp;feed=atom&amp;title=Flask_in_a_container</id>
	<title>Flask in a container - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://pzwiki.wdka.nl/mw-mediadesign/index.php?action=history&amp;feed=atom&amp;title=Flask_in_a_container"/>
	<link rel="alternate" type="text/html" href="https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;action=history"/>
	<updated>2026-08-04T11:26:53Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.38.2</generator>
	<entry>
		<id>https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=336734&amp;oldid=prev</id>
		<title>SHRED at 12:00, 7 July 2026</title>
		<link rel="alternate" type="text/html" href="https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=336734&amp;oldid=prev"/>
		<updated>2026-07-07T12:00:31Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 14:00, 7 July 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l82&quot;&gt;Line 82:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 82:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category: Tommi’s to-do list]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;[[Category: Tommi’s to-do list]]&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[Category:flask]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>SHRED</name></author>
	</entry>
	<entry>
		<id>https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=331408&amp;oldid=prev</id>
		<title>Tommi: Add image with graph</title>
		<link rel="alternate" type="text/html" href="https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=331408&amp;oldid=prev"/>
		<updated>2026-04-14T10:18:44Z</updated>

		<summary type="html">&lt;p&gt;Add image with graph&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 12:18, 14 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot;&gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The de-facto standard to deal with container is [https://docker.com Docker], and it is nearly ubiquitous. Nevertheless, this guide uses [https://podman.io Podman], a drop-in replacement that offers some benefits. This means that at any point of the article and also more in general whenever there is a &amp;lt;code&amp;gt;docker&amp;lt;/code&amp;gt; command, it can be replaced with &amp;lt;code&amp;gt;podman&amp;lt;/code&amp;gt;, and it should work the same. The reasons behind this choice are beyond the scope of this little guide, but I gathered my notes and thoughts about Podman [https://tommi.space/podman/ in the dedicated page].&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;The de-facto standard to deal with container is [https://docker.com Docker], and it is nearly ubiquitous. Nevertheless, this guide uses [https://podman.io Podman], a drop-in replacement that offers some benefits. This means that at any point of the article and also more in general whenever there is a &amp;lt;code&amp;gt;docker&amp;lt;/code&amp;gt; command, it can be replaced with &amp;lt;code&amp;gt;podman&amp;lt;/code&amp;gt;, and it should work the same. The reasons behind this choice are beyond the scope of this little guide, but I gathered my notes and thoughts about Podman [https://tommi.space/podman/ in the dedicated page].&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-side-deleted&quot;&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;[[File:Flask container graph.png|thumb]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;br/&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Make a Dockerfile ==&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;== Make a Dockerfile ==&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Tommi</name></author>
	</entry>
	<entry>
		<id>https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=331383&amp;oldid=prev</id>
		<title>Tommi: Create initial page</title>
		<link rel="alternate" type="text/html" href="https://pzwiki.wdka.nl/mw-mediadesign/index.php?title=Flask_in_a_container&amp;diff=331383&amp;oldid=prev"/>
		<updated>2026-04-14T08:26:45Z</updated>

		<summary type="html">&lt;p&gt;Create initial page&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Running Flask in a container is tremendously useful to move the same container anywhere and replicate the same exact environment on any device or operating system, without having to modify anything.&lt;br /&gt;
&lt;br /&gt;
== Why a container? ==&lt;br /&gt;
&lt;br /&gt;
A container can be seen a bit like a box with compartments inside it. Running an application (in this case, Flask) on different devices with different operating systems would be like taking different boxes and try to recreate the same compartments inside them, or trying to fit them even if the size of the containing box is not identical. The software equivalent of this would be to install all the dependencies and the required software independently on each device, to try to reach the same result. Using a container would be like taking the original box and move it around, without having to change or adapt its internal structure. Creating a container means that from one device we &amp;lt;q&amp;gt;pack&amp;lt;/q&amp;gt; everything that is needed, and then we can ship it (&amp;lt;q&amp;gt;deploy&amp;lt;/q&amp;gt; it) anywhere.&lt;br /&gt;
&lt;br /&gt;
== Podman ==&lt;br /&gt;
&lt;br /&gt;
The de-facto standard to deal with container is [https://docker.com Docker], and it is nearly ubiquitous. Nevertheless, this guide uses [https://podman.io Podman], a drop-in replacement that offers some benefits. This means that at any point of the article and also more in general whenever there is a &amp;lt;code&amp;gt;docker&amp;lt;/code&amp;gt; command, it can be replaced with &amp;lt;code&amp;gt;podman&amp;lt;/code&amp;gt;, and it should work the same. The reasons behind this choice are beyond the scope of this little guide, but I gathered my notes and thoughts about Podman [https://tommi.space/podman/ in the dedicated page].&lt;br /&gt;
&lt;br /&gt;
== Make a Dockerfile ==&lt;br /&gt;
&lt;br /&gt;
The first step is to make a [https://docs.docker.com/build/concepts/dockerfile/ Dockerfile], giving Podman/Docker the &amp;lt;q&amp;gt;instructions&amp;lt;/q&amp;gt; to pack the box, which means taking all the software and dependencies necessary to run Flask and place them inside the container.&lt;br /&gt;
&lt;br /&gt;
I have not learned how a Dockerfile actually works (yet). I just made a patchwork of the different Dockerfile examples I found—referenced below.&lt;br /&gt;
&lt;br /&gt;
Here is the essential Dockerfile to run an instance of Flask, block by block.&lt;br /&gt;
&lt;br /&gt;
Download (“pull”) the required images to run the container. In this case, we are pulling Python and [https://docs.astral.sh/uv/ uv], and we are telling Podman to move the executable binaries to specific folders in the container.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;FROM python:3.12-slim-trixie&lt;br /&gt;
COPY --from=ghcr.io/astral-sh/uv:0.11 /uv /uvx /bin/&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Assuming that all the files required to run Flask are in &amp;lt;code&amp;gt;./app&amp;lt;/code&amp;gt;, we mat them all to &amp;lt;code&amp;gt;/app&amp;lt;/code&amp;gt;, inside the container.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;# Copy over project files&lt;br /&gt;
COPY app/ /app&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tell the container that we are referring to &amp;lt;code&amp;gt;/app&amp;lt;/code&amp;gt; (the directory we just created) whenever we run or do something. In other terms, it is our the working directory of the container.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;WORKDIR /app&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Tell uv to install the required dependencies, listed in &amp;lt;code&amp;gt;pyproject.toml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;RUN uv sync -U&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Flask runs through a specific port. We have to tell the container to &amp;lt;q&amp;gt;expose&amp;lt;/q&amp;gt; that port, to make available. This does not mean the port is directly exposed to the outside world, it is just “handed over” and made available to Podman, that can be instructed to actually serve that port (see below).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;EXPOSE 5000&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
I couldn’t find a nicer way to do it, but basically this is the final command to be run when the container should be running&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=Dockerfile&amp;gt;CMD [&amp;quot;uv&amp;quot;, &amp;quot;run&amp;quot;, &amp;quot;flask&amp;quot;, &amp;quot;--app&amp;quot;, &amp;quot;main&amp;quot;, &amp;quot;run&amp;quot;, &amp;quot;--debug&amp;quot;, &amp;quot;--host&amp;quot;, &amp;quot;0.0.0.0&amp;quot;, &amp;quot;--port&amp;quot;, &amp;quot;5000&amp;quot;]&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
this is the same as running the following in the command line, which is exactly what we are telling the container to do as the last action of the Dockerfile.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;uv run flask --app main run --debug --host '0.0.0.0' --port '5000'&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
The complete Dockerfile is [https://git.xpub.nl/tommi/flask-intro/src/branch/main/Dockerfile here], in the [https://git.xpub.nl/tommi/flask-intro flask-intro repository].&lt;br /&gt;
&lt;br /&gt;
== Build the container ==&lt;br /&gt;
&lt;br /&gt;
Once the instructions are compiled, the container has to be built. It’s possible to specify which Dockerfile to read, using &amp;lt;code&amp;gt;-f&amp;lt;/code&amp;gt;. By default, the reference Dockerfile is &amp;lt;code&amp;gt;Dockerfile&amp;lt;/code&amp;gt; in the present working directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;podman build -t flask-intro:latest # -f Dockerfile&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Run the container ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;podman run --rm --name flask-intro -p 5000:5000 flask-intro&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
== Production vs development mode ==&lt;br /&gt;
&lt;br /&gt;
\#TODO))&lt;br /&gt;
&lt;br /&gt;
== Create Quadlet ==&lt;br /&gt;
&lt;br /&gt;
\#TODO))&lt;br /&gt;
&lt;br /&gt;
== Serve with Caddy ==&lt;br /&gt;
&lt;br /&gt;
\#TODO))&lt;br /&gt;
&lt;br /&gt;
== Resources ==&lt;br /&gt;
&lt;br /&gt;
* [https://medium.com/@brianmayrose/basic-flask-setup-with-podman-6024ba6769e5 Basic Flask Setup With Podman] by Brian Mayrose&lt;br /&gt;
* [https://docs.astral.sh/uv/guides/integration/docker/ Using uv in Docker], from the uv documentation&lt;br /&gt;
* [https://nickjanetakis.com/blog/switching-pip-to-uv-in-a-dockerized-flask-or-django-app Switching pip to uv in a Dockerized Flask / Django App] by Nick Janetakis&lt;br /&gt;
* [https://rest-apis-flask.teclado.com/docs/deploy_to_render/docker_with_gunicorn/ Run our Flask app with gunicorn in Docker | REST APIs with Flask and Python]&lt;br /&gt;
* [https://github.com/nickjj/docker-flask-example GitHub - nickjj/docker-flask-example: A production ready example Flask app that's using Docker and Docker Compose. · GitHub]&lt;br /&gt;
* [https://testdriven.io/blog/dockerizing-flask-with-postgres-gunicorn-and-nginx/ Dockerizing Flask with Postgres, Gunicorn, and Nginx | TestDriven.io]&lt;br /&gt;
&lt;br /&gt;
{{Youtube|twv_kCq693o}}&lt;br /&gt;
&lt;br /&gt;
{{Youtube|YH9skYpTzxQ}}&lt;br /&gt;
&lt;br /&gt;
{{Youtube|Vlr2q6gWl_Q}}&lt;br /&gt;
&lt;br /&gt;
{{Youtube|KWIIPKbdxD0}}&lt;br /&gt;
&lt;br /&gt;
[[Category: Tommi’s to-do list]]&lt;/div&gt;</summary>
		<author><name>Tommi</name></author>
	</entry>
</feed>