I am running NetCore project with docker support. My docker-compose.override.yml:
version: '3.4'
services:
  traefik:
    ports:
      - '80:80'
      - '443:443'
      - '8080:8080'
  myapi:
    environment:
      - 'ASPNETCORE_ENVIRONMENT=Development'
      - 'ConnectionStrings:DbConnection=postgresql://postgres'
      - 'Services:Authorization=http://10.0.75.1'
      - 'Authorization:Url=http://10.0.75.1'
  postgres:
    environment:
      POSTGRES_USER: "user"
      POSTGRES_PASSWORD: "pass"
      POSTGRES_DB: testdb
    ports:
      - 5432:5432
  pgadmin4:
    environment:
      - [email protected]
      - PGADMIN_DEFAULT_PASSWORD=SuperSecret
    ports:
     - 19000:80
And docker-compose.yml:
version: '3.4'
services:
  traefik:
    image: traefik
    command: --web --docker --docker.domain=docker --logLevel=DEBUG
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - /develop/traefik/acme:/etc/traefik/acme
  postgres:
    image: postgres
    labels: { "traefik.enable":"false" }
  myapi:
    image: myapi
    build:
      context: .
      dockerfile: MyApi/Dockerfile
    links:
      - postgres
    labels: { "traefik.backend":"myapi", "traefik.frontend.rule":"PathPrefixStrip:/" }
  pgadmin4:
    image: dpage/pgadmin4
    links:
      - postgres
I can't bind connection string from myapi service to postgres docker container. I have also tried with postgresql://postgres:postgres@db:5432, and postgresql://, and just postgres, no luck.
I am getting log:
System.ArgumentException: Format of the initialization string does not conform to specification starting at index 0.
So obviously i cannot reach the db server.
My original connection string, when I run app locally, works great, in form:
User ID = user;Password=pass;Server=localhost;Port=5432;Database=testdb;Integrated Security=true;Pooling=true
Any ideas how to map my service with postgres in docker here? Thx!
I think you should use this:
User ID = user;Password=pass;Server=postgres;Port=5432;Database=testdb;Integrated Security=true;Pooling=true
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With