the是
docker-compose
文件:
services:
flightproject.webapi:
image: ${DOCKER_REGISTRY-}flightprojectwebapi
container_name: flightproject.webApi
ports:
- 8080:8080
- 8081:8081
build:
context: .
dockerfile: FlightProject.WebApi/Dockerfile
flightproject.database:
image: postgres:latest
container_name: flightproject.database
environment:
- POSTGRES_DB=flightproject
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=postgres
ports:
- 5432:5432
volumes:
- ./.containers/flightproject-db:/var/lib/postgresql/data
flightproject.client:
image: ${DOCKER_REGISTRY-}flightprojectclient
container_name: flightproject.client
ports:
- 5251:8080
build:
context: .
dockerfile: FlightProject.UIClient/Dockerfile
the是Web API项目的
launchSettings.json
文件:{
"profiles": {
"http": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:5125"
},
"https": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "https://localhost:7296;http://localhost:5125"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"launchUrl": "swagger",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"Container (Dockerfile)": {
"commandName": "Docker",
"launchBrowser": true,
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
"environmentVariables": {
"ASPNETCORE_HTTPS_PORTS": "8081",
"ASPNETCORE_HTTP_PORTS": "8080"
},
"publishAllPorts": true,
"useSSL": true
}
},
"$schema": "http://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:39595",
"sslPort": 44356
}
}
}
当我通过将容器设置为启动项目并运行它时,Web API始终会分配一些奇怪的端口,但也指定了8080和8081。运行
i我试图在
docker-compose
文件中更改运行端口,也试图在docker-compose
文件中更改运行端口,并希望这将解决问题。我还试图通过删除Web API中的一些行来删除招摇的支撑,但这并没有改变。
我遇到了同样的问题,经过大量的反复试验,我弄清楚了。问题是在运行时设置应用程序的主机端口。在容器上,HTTP/HTTPS端口为8080/8081。从本地主机ping时,host_port设置端口使用。要将这些端口设置为docker-compose
,然后将httpport和sslport属性设置为您想要的任何端口
launchSettings.json