Docker Compose + Spring Boot + Postgres connection

后端 未结 3 1546
孤街浪徒
孤街浪徒 2021-02-12 17:15

I have a Java Spring Boot app which works with a Postgres database. I want to use Docker for both of them. I initially put just the Postgres in Docker, and I had a docker-

3条回答
  •  余生分开走
    2021-02-12 17:27

    You can use this.

    version: "2"
    services:
        sample_db-postgresql:
            image: postgres:9.5
            ports:
                - 5432:5432
            environment:
                - POSTGRES_PASSWORD=sample
                - POSTGRES_USER=sample
                - POSTGRES_DB=sample
             volumes:
                - sample_db:/var/lib/postgresql/data
    
    volumes:
        sample_db:
    

提交回复
热议问题