Automating Postgres Deployment with Docker Compose and Init Scripts

Introduction to Running PostgreSQL in a Docker Container using Docker Compose In this blog post, we will explore how to run PostgreSQL in a Docker container using Docker Compose. We will also break down and explain the init-user-db.sh script that is executed at startup to initialize the PostgreSQL tables. Running PostgreSQL in a Docker container provides several benefits, including ease of deployment, portability, and isolation. So let’s dive in and understand the process! ...

January 6, 2024 · 5 min · Tom Cocking

How To call a bash command with variables in Python

Updated October 2026: the code in my 2020 version of this post didn’t run. It used : where it needed =, wrote Import with a capital, and passed a command string to Popen without a shell, which raises FileNotFoundError. I’ve rewritten the examples, run every one on Python 3.14.4, and added the part I should have warned you about, which is shell injection. A quick Google of the title only gave me answers for the inverse, calling a Python script from bash and handing it variables. At least the first three results did, and I’m probably not alone in scrolling past the Stack Overflow answers. ...

December 28, 2020 · 6 min · Tom Cocking