用于Linux的PostgreSQL的.NET Core容器

时间:2019-04-07 14:47:29

标签: postgresql docker asp.net-core docker-compose

在我的VS2017解决方案中,我添加了docker支持,以便对我的应用进行dockerize并将其安装在Linux上。

docker-compose.yml

version: '3.4'

networks:
  net-delivery-dev:
    driver: bridge

services:
  # Application
  delivery.api:
    image: ${DOCKER_REGISTRY-}delivery.api
    build:
      context: ../../src/
      dockerfile: delivery.api/Dockerfile
    environment:
      DB_CONNECTION_STRING: "<connection string>"
    depends_on: 
      - "db"
    networks:
      - net-delivery-dev

  # Database (postgresql)
  db:
    image: postgres:9.6
    restart: 'always'
    ports: 
      - '5432:5432'
    #build: './postgres'
    environment:
      - "POSTGRES_USER:<usr>"
      - "POSTGRES_PASSWORD:<pwd>"
    volumes:
      # Persist the data between container invocations
      - postgresVolume:/var/lib/postgresql/data
      - ./logs:/logs
      - ./postgres/initdb.sql :/docker-entry-initdb/initdb.sql
    networks:
      - net-delivery-dev

# Creates a named volume to persist our data.
volumes:
  postgresVolume:

将VS2017中的容器发布到Docker Hub正常工作。 但是,当我转到Linux服务器时,我启动docker pull来检索映像,然后:

docker run --rm -p 81:80 -e "ASPNETCORE_URLS=http://+:80" -dt --name "trial" <repo>/delivery.api:latest

这部分仅启动.NET Core应用程序,而不启动Postgresql服务器。

docker logs <id>
Hosting environment: Production
Content root path: /app
Now listening on: http://[::]:80
Application started. Press Ctrl+C to shut down.

我如何设法同时启动这两项服务?

此致

0 个答案:

没有答案