简体   繁体   English

文件存在于 docker run 卷中,但不存在于 docker-compose 卷中

[英]File exists in docker run volume but not docker-compose volume

I'm trying to figure out why I can find a certificate file in a volume using:我试图弄清楚为什么我可以使用以下方法在卷中找到证书文件:

docker run -v ~/.aspnet/https:/https:ro -p 80:80 -p 443:433 -e ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx -e ASPNETCORE_Kestrel__Certificates__Default__Password=<MY PASSWORD HERE> housesearchwebsite

but not using:但不使用:

docker-compose -f docker-compose.custom.yml up

with a docker-compose.custom.yml that looks like this: (sensitive information removed)使用 docker-compose.custom.yml 看起来像这样:(删除了敏感信息)

version: '3.4'

services:   
  housesearchwebsite:
    image: housesearchwebsite
    environment:
      - ASPNETCORE_ENVIRONMENT=Development
      - ASPNETCORE_URLS=https://+:443;http://+:80
      - ConnectionString=host=db;port=5432;database=<DATABASENAME>;username=<DBUSERNAME>password=<MY DB PASSWORD>
      - ASPNETCORE_Kestrel__Certificates__Default__Password=<MY PASSWORD HERE>
      - ASPNETCORE_Kestrel__Certificates__Default__Path=/https/aspnetapp.pfx
    ports:
      - "80"
      - "443"
    volumes:
      - ${HOME}/.aspnet/https:/https:ro
      - images_volume:/var/lib/housesearch/images
    networks:
      - dev-net

volumes:
  images_volume:

networks:
  dev-net:
    name: dev-net

I have some C# code that checks, first thing, if there is a aspnetapp.pfx file in the ASPNETCORE_Kestrel__Certificates__Default__Path path, but it is only found if I run the docker run command, and is not found if I use the docker-compose command.我有一些 C# 代码,首先检查ASPNETCORE_Kestrel__Certificates__Default__Path路径中是否有 aspnetapp.pfx 文件,但只有在我运行ASPNETCORE_Kestrel__Certificates__Default__Path run 命令时才能找到它,如果我使用 docker-compose 命令则找不到它。

Not sure why it started working randomly, but an issue I can clearly flag which might have been the reason for your error is that you are not mapping the ports properly in your docker-compose.yml .不知道为什么它开始随机工作,但我可以清楚地指出一个问题,这可能是导致您错误的原因是您没有在docker-compose.yml正确映射端口。

Ports should be defined as:端口应定义为:

ports:
 - "80:80"
 - "443:443"

Where the mapping would be in HOST:CONTAINER format.映射将采用HOST:CONTAINER格式。

Docs here文档在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM