Today I Learned ~D[2025-06-02]

File this under “things I knew but have to look up everytime”…

If you want to spin up a Docker container without a service like postgres , for example if you had a fully seeded DB on your machine and didn’t want to go through the hassle of copying/re-seeding in Docker, you can do so with host.docker.internal. In docker-compose.yml you can write:

environment:
      - DB_HOST=host.docker.internal
      - DB_PORT=5432
      - DB_USERNAME=your_pg_user
      - DB_PASSWORD=your_password
      - DB_NAME=your_db

Because I switch projects a lot (agency life) there are occasions where a legacy codebase just stops working (system updates, depercations, etc.) at times like these I like falling back to the Docker container (upgrading the project is not always an option) but I may not want to loose/copy all my data from when I worked on the project before. Yes, I know dev data should be ephemeral and easy to reseed but in the real world this is not always how things work!