Free Web Developer Utility

Docker Compose Generator

Containerize ASP.NET Core web services and PostgreSQL. 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

Wire your ASP.NET Core C# API container to PostgreSQL. Our template sets up environment variables to inject database credentials directly into your appsettings.json datasource configuration. 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.

Optimized Dockerizing for .NET Web APIs

Multi-Stage Build Structure

Compile using the full mcr.microsoft.com/dotnet/sdk image. Once compiled, publish your release artifacts and run them inside the lightweight aspnet runtime image, minimizing disk size.

Mapping C# App Connection Strings

Use double underscores (__) in environment variables to map nested appsettings JSON values. For example, ConnectionStrings__DefaultConnection maps directly to ConnectionStrings.DefaultConnection.

Production DockerfileOptimized
# Stage 1: Compile Application
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build-env
WORKDIR /app
COPY *.csproj ./
RUN dotnet restore
COPY . ./
RUN dotnet publish -c Release -o out

# Stage 2: Runtime Runner
FROM mcr.microsoft.com/dotnet/aspnet:8.0
WORKDIR /app
COPY --from=build-env /app/out .
EXPOSE 8080
ENTRYPOINT ["dotnet", "App.dll"]

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 do I pass database credentials to ASP.NET Core?

Use environment variables in your compose file that override your appsettings config, e.g. ConnectionStrings__DefaultConnection='Host=postgres-db;Database=mydb;Username=postgres;Password=pwd'.

Can I run Entity Framework migrations in Docker?

Yes. You can execute migrations on startup by calling db.Database.Migrate() inside Program.cs, or run dotnet-ef commands inside the SDK container.

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.