Free Web Developer Utility

Docker Compose Generator

Create Python & PostgreSQL Docker Compose networks. Pick your services, configure environments, and download your compose file.

Quick Start Guide

How to use the compiler tool in 3 simple steps:

1. Select Stack

Select Web Proxies, Backend Languages, and Databases in the selector grid.

2. Configure Properties

Adjust container labels, network ports, and custom environment variables in tabs.

3. Copy & Deploy

Instantly copy or download the generated `docker-compose.yml` to run in your terminal.

Quick Stacks:

Select Services

Enable the components needed in your container network. We'll automatically wire up database dependencies and port configurations.

Web Proxy

Languages & Frameworks

Databases & Caching

NODE_ENV
production
PORT
3000

Live Network Flow

Web
Client
NODE

docker-compose.yml

# =========================================================================
# Generated dynamically by HYVO Docker Compose Builder (hyvo.in)
# =========================================================================

services:
  node:
    image: node:20-alpine
    container_name: node-app
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - PORT=3000

About the Docker Compose Generator Tool

Python backend services like FastAPI or Django rely heavily on relational storage. This builder wires your Python app (running Uvicorn/Gunicorn) to PostgreSQL with automated environmental injections. Our free online Docker Compose builder resolves the configuration hurdles developers face when setting up multi-container networks locally. Manually writing YAML can lead to spelling errors, indentation crashes, and network connection issues. This tool automates the creation of a clean `docker-compose.yml` file, matching exposed host ports, linking dependencies via `depends_on`, setting restart limits, and configuring persistent named volumes for databases.

FastAPI & PostgreSQL Docker Build Optimization

Avoiding Python Log Buffering

Always set PYTHONUNBUFFERED=1. This forces stdout and stderr streams to write directly to your console, allowing you to debug application initialization failures using docker compose logs in real-time.

Minimizing Image Size with Slim Bases

Use python:3.11-slim rather than full alpine images. Alpine requires manual compilation of C-bindings for packages like psycopg2, while slim provides precompiled wheel compatibility, speeding up installs.

Production DockerfileOptimized
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

What is Containerization?

Containerization is a lightweight form of virtualization that packages an application's code, dependencies, libraries, and configurations into a single executable package called a container. Unlike virtual machines (VMs) that require a full guest operating system, containers share the host OS kernel, making them incredibly fast to boot, memory-efficient, and portable across developer laptops, staging servers, and cloud clusters.

What is Docker?

Docker is the industry-standard software platform used to build, share, and run containerized applications. By utilizing a Dockerfile, you specify the exact steps to compile your app. Docker packages these instructions into a immutable "Docker Image." When you run that image, it becomes a "Docker Container." This ensures your application behaves exactly the same in local development as it does in production, eliminating the classic "works on my machine" problem.

What is Docker Compose?

If your application relies on more than one container (e.g., a frontend app, a backend API, a PostgreSQL database, and a Redis cache), running them manually using single `docker run` commands is tedious. You have to manually set up virtual networks, link ports, manage container dependencies, and map storage paths.

**Docker Compose** solves this by letting you define your entire multi-container application stack in a single YAML file (`docker-compose.yml`). With a simple command—`docker compose up`—Docker automatically spins up all the services, builds the virtual bridge networks, mounts storage volumes, and starts log streams.

Understanding Docker Compose settings

Exposed Ports

Mapped as `host:container` (e.g. `3000:3000`). The first port exposes the service to your host machine (localhost), while the second port is the internal port the app listens to inside the container.

Persistent Volumes

Named volumes (e.g. `postgres_data`) map directory paths inside the database container to the host storage. This ensures your database records, users, and tables are saved when you stop your container.

Service Networks

Docker Compose automatically sets up a shared bridge network. All services in the same file can reach each other using their container name (e.g., connection host becomes `postgres-db`).

How to Use the Generated File

1

Save the File

Download the file and save it exactly as `docker-compose.yml` in the root folder of your project.

2

Verify Docker Installation

Ensure you have Docker Desktop (Windows/macOS) or Docker Engine (Linux) installed and running on your machine.

3

Start your containers

Open your terminal in the directory of your file and run: `docker compose up` or `docker compose up -d` (to run in the background).

Frequently Asked Questions

How does FastAPI connect to Postgres inside Docker?

Use 'postgres-db:5432' as the host in your SQL Alchemy or databases URL, e.g., 'postgresql://postgres:postgres_password@postgres-db:5432/mydb'.

Why is PYTHONUNBUFFERED=1 set in environment?

It ensures Python prints logs directly to stdout/stderr in real-time without buffering, making 'docker compose logs' updates immediate.

What is a dynamic Docker network?

Docker Compose sets up a single network for your application by default. Each container joins the default network and is both reachable by other containers on that network, and discoverable by them at a hostname identical to the container name.

How do I verify container status?

Use the command `docker compose ps` to inspect running containers, mapped ports, and health statuses, or view them inside the graphical interface of Docker Desktop.

Build and scale with HYVO

Don't spend hours debugging Docker network links. Use this generator to wire your stack, and let our senior engineering collective build out your product.