Looks like someone had a similar question recently #13012 which helped me solve the above issue!

Basically, in the local env file, ensure you use localhost as the hostname

DATABASE_URL="postgresql://nest-twitter:password@localhost:5432/nest-twitter-db?schema=public"

This means when you run npx prisma studio it connects to the local postgres instance in Docker with no issues.

However, this will then break the Docker services from working together as you need to use postgres as the hostname.

So what you can do in the docker-compose.yml file is define an overriding DATABASE_URL environment variable, using postgres as the hostname

version: "3.9"
services:
  api:
    build:
      dockerfile: Dockerfile
      context: .
      # Only will build development stage from our dockerfile
      target: development
    # TBC
    volumes:
      - .:/usr/src/app
      - ./usr/src/app/node_modules
    # Run in dev Mode: npm run start:dev
    command: npm run start:dev
    depends_on: 
      - postgres
    env_file:
    - .env
    environment:
    - DATABASE_URL=postgresql://nest-twitter:password@postgres:5432/nest-twitter-db?schema=public
    ports:
      - 3000:3000
  postgres:
    image: postgres
    restart: always
    environment:
      POSTGRES_NAME: nest-twitter-db
      POSTGRES_USER: nest-twitter
      POSTGRES_PASSWORD: password
    ports: 
      - '5432:5432'
    volumes:
      - nest-twitter-db:/var/lib/postgresql/data

volumes:
  nest-twitter-db:
🌐
Prisma
prisma.io › home › docker › docker › docker
How to use Prisma in Docker | Prisma Documentation
Run the app and database together with Docker Compose3.1. Option 1: Use Linux Alpine (node:alpine) as a base image3.1. Option 2: Use Linux Debian (node:slim) as a base image3.2. Create and configure a Docker Compose file3.3. Configure environment variable for the container3.4. Build and run the application3.5. Bonus: Add Prisma Studio for database management
🌐
Docker Hub
hub.docker.com › r › timothyjmiller › prisma-studio
timothyjmiller/prisma-studio - Docker Image
Use the included docker-compose.yml file as a base for your installation. version: '3.7' services: prisma-studio: container_name: prisma-studio image: timothyjmiller/prisma-studio:latest restart: unless-stopped env_file: - .env ports: - ${PRISMA_STUDIO_PORT}:5555 postgres: container_name: prisma-postgres image: postgres:alpine restart: always env_file: - .env ports: - ${POSTGRES_PORT}:5432 volumes: - ${POSTGRES_PATH}/${PROJECT_NAME}/${POSTGRES_DATABASE}/:/var/lib/postgresql/data healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 Copy
🌐
Adamjberkowitz
adamjberkowitz.com › blog › post › starting-with-prisma-and-docker
Adam Berkowitz - Starting with Prisma and Docker
I knew that these three things needed to be hooked together within a docker context using docker-compose · The good news is that prisma has a docker image and documentation on how to get started.
🌐
Reddit
reddit.com › r/prismaorm › access prisma studio via docker
r/prismaorm on Reddit: Access Prisma Studio via Docker
September 26, 2024 - hello devs i am having quite trouble in accessing prisma studio.. can anyone help me i have spin up the postgres and nextjs container and access it locally successfully. but have no idea how to access prisma studio : when you run bunx prisma studio. services: nextjs: container_name: nextjs-0.1 build: context: . dockerfile: Dockerfile.dev command: sh -c "bunx prisma db push && bun run dev --turbo" volumes: - .:/app env_file: - .env ports: - 3000:3000 depends_on: postgresql: condition: service_healthy postgresql: container_name: postgresql-database image: postgres:15-alpine env_file: - .env healthcheck: test: ["CMD-SHELL", "pg_isready"] interval: 1m30s timeout: 30s retries: 5 start_period: 30s ports: - 5432:5432 expose: - 5432 volumes: - pgvolume:/var/lib/postgresql/data volumes: pgvolume:
🌐
Medium
baccini-al.medium.com › how-to-set-up-prisma-with-a-local-docker-postgres-container-9e0958d08544
How to set up Prisma with a local Docker Postgres container | by Alessandro Baccini | Medium
August 8, 2023 - If you need to replicate this behavior while using a standalone container with the docker run directive simply add the -v flag with the following syntax: -v /your/volume/path:/var/run/postgresql · When you declare the path of your local volume ensure that it exists or it will throw an error. npx prisma db pull ·
🌐
Stack Overflow
stackoverflow.com › questions › 74183615 › prisma-studio-image-in-docker-cant-be-pulled
Prisma Studio Image in Docker can't be pulled - Stack Overflow
version: '3.9' services: prisma-studio: container_name: prisma-studio image: timothyjmiller/prisma-studio:latest restart: unless-stopped ports: - '5555:5555' env_file: - ./server/.env depends_on: - db db: image: postgres:13 ports: - '5432:5432' env_file: - ./server/.env volumes: - ./server/.dbdata:/var/lib/posgtgres api: container_name: api build: context: ./server dockerfile: Dockerfile.dev ports: - '4000:4000' volumes: - .:/app depends_on: - db client: container_name: client build: context: ./client dockerfile: Dockerfile.dev ports: - '3000:3000' depends_on: - api volumes: .dbdata:
Find elsewhere
🌐
GitHub
github.com › prisma › studio › issues › 296
Docker and prisma studio · Issue #296 · prisma/studio
November 25, 2019 - After upgrading to prisma2 preview 17, I modified my Dockerfile in order to assure that @prisma/photon is installed. When I dockerize my app I got this error when I try to open prisma studio on http://localhost:5555 Error dump Cannot des...
Author   prisma
🌐
DevGenius
blog.devgenius.io › setting-up-prisma-with-postgresql-using-docker-056e63a312ee
Setting Up Prisma with PostgreSQL Using Docker | by Lokendra Kushwah | Dev Genius
January 24, 2025 - In this guide, we’ll walk through setting up Prisma with a PostgreSQL database using Docker. This setup is perfect for developers looking…
🌐
GitHub
github.com › prisma › studio › issues › 1218
Prisma + docker + docker compose + NGINX · Issue #1218 · prisma/studio
Bug description nginx cannot direct port 5555 of the container that is running Prisma Studio Pro https, Prisma Studio only runs on HTTP if you enter the domain name :5555 ex: http://exampledominio.com:5555 How to reproduce Use a small ba...
Author   prisma
🌐
Prisma
prisma.io › studio
Prisma Studio | Visual Database Browser and Editor
Access Prisma Studio on your local machine during development, or in the Prisma Console to collaborate on data with your team.Explore Studio in Console
🌐
Docker Hub
hub.docker.com › r › codejamninja › prisma-studio
codejamninja/prisma-studio - Docker Image
docker run -e POSTGRES_URL=postgresql://user:pass@localhost5432/data?schema=data codejamninja/prisma-studio Copy
🌐
GitHub
github.com › prisma › studio › blob › main › docker-compose.yml
studio/docker-compose.yml at main · prisma/studio
🎙️ The easiest way to explore and manipulate your data in all of your Prisma projects. - studio/docker-compose.yml at main · prisma/studio
Author   prisma
🌐
Medium
dailydevnote.medium.com › using-prisma-with-node-js-in-a-dockerized-environment-127e63752aa7
Using Prisma with Node.js in a Dockerized Environment | by Aung Thu Oo | Medium
September 22, 2024 - Open the file .dockerignore and add the following content: ... FROM node:20 WORKDIR /app COPY package*.json ./ RUN npm install COPY prisma ./prisma RUN npx prisma generate COPY .
🌐
Medium
medium.com › @abhijariwala › dockerizing-a-next-js-and-node-js-app-with-postgresql-and-prisma-a-complete-guide-000527023e99
Dockerizing a Next.js and Node.js App with PostgreSQL and Prisma: A Complete Guide | by Abhi jariwala | Medium
May 25, 2024 - "scripts": { "test": "echo \"Error: no test specified\" && exit 1", "run:dev": "set NODE_ENV=development && nodemon src/app.ts", "start:dev": "set NODE_ENV=development && node dist/app.js", "start:prod": "set NODE_ENV=production && nodemon src/app.ts", "prisma:format": "dotenv -e .env.development -- npx prisma format", "prisma:generate": "dotenv -e .env.development -- npx prisma generate", "prisma:migrate": "dotenv -e .env.development -- npx prisma migrate dev", "prisma:push": "dotenv -e .env.development -- npx prisma db push", "prisma:studio": "dotenv -e .env.development -- npx prisma studio", "build": "tsc -p ." } Dockerfile for Backend ·
🌐
Medium
medium.com › @imrabin1998 › how-to-dockerize-mongodb-for-prisma-with-replica-sets-48ea08c77635
How to Dockerize MongoDB for Prisma with Replica Sets? | by Rabin Thapa | Medium
September 6, 2024 - While I’ve had experience containerizing databases before, I encountered some unique challenges when working with Prisma. Unlike other setups, dockerizing a Prisma requires MongoDB to be running in the replica set. Generally, replica sets are used for data redundancy.
🌐
Docker Hub
hub.docker.com › r › mesh7 › prisma-studio
mesh7/prisma-studio - Docker Image
© 2026 Docker, Inc. All rights reserved. | Terms of Service | Subscription Service Agreement | Privacy | Legal
🌐
egghead.io
egghead.io › q › docker-and-pm2-and-prisma
Learn Docker, Pm2 and Prisma | egghead.io
expert led courses for front-end web developers and teams that want to level up through straightforward and concise lessons on the most useful tools available.
🌐
Docker Hub
hub.docker.com › r › prismagraphql › prisma
prismagraphql/prisma - Docker Image
The Docker CLI⁠ and Docker Compose CLI⁠ are used to manage the Prisma servers.