Docker Linux / Window容器设置服务器时区DotnetCore映像

时间:2019-07-29 17:23:41

标签: docker .net-core

我只是想知道如何通过Dockerfile或Docker-Compose更改服务器时间成为我想要的时区。

例如,这是我用于DotnetCore WebApi的DockerFile。

FROM microsoft/dotnet:2.2-sdk

# Install vsdbg for remote debuging, allow us to debug code in out host machine.
RUN apt-get update \
    && apt-get install -y curl unzip \
    && curl -sSL https://aka.ms/getvsdbgsh | bash /dev/stdin -v latest -l /vsdbg

# Required inside Docker, otherwise file-change events may not trigger.
ENV DOTNET_USE_POLLING_FILE_WATCHER 1

# Set a working dir, and map to this host machine in docker-compose
WORKDIR /app
EXPOSE 5000

# By copying these into the image when building it, we don't have to re-run restore everytime we launch a new container.
COPY ["sample.csproj", "./"]
COPY ["Directory.Build.props", "./"]
RUN dotnet restore

# This will build and launch the server in a loop, restarting whenever a *.cs file changes.
ENTRYPOINT [ "dotnet", "watch", "run", "--urls", "http://0.0.0.0:5000"]

Docker-Compose

version: '3.7'

networks: 
  webapi-dev:
    driver: bridge

services:

  webapi-netcore:
    container_name: netcore.development
    depends_on:
      - "postgres_image"
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "5000:5000"
    volumes:
      - ./:/app
    environment:
      ASPNETCORE_ENVIRONMENT: "Development"
      POSTGRES_CONNECTION_STRING: "some-connection"
    networks:
      - webapi-dev

  postgres_image:
    image: postgres:latest
    container_name: prostgres.development
    ports:
      - "5432:5432"
    restart: always
    volumes:
      - db_volume:/var/lib/postgresql/data
    environment:
      POSTGRES_USER: "dev"
      POSTGRES_PASSWORD: "dev"
      POSTGRES_DB: "dev"
    networks:
      - webapi-dev

volumes:
  db_volume:

0 个答案:

没有答案