Docker-compose file, Dockerfile and launchSettings.json file create many port bindings

Why does my docker-compose file, Dockerfile and launchSettings.json file create many port bindings when I only declared two:

docker compose file:

ports:

  • “5049:5049”
  • “7040:7040”
    depends_on:
  • sql
    environment:
  • ASPNETCORE_ENVIRONMENT=DockerSql
  • ASPNETCORE_URLS=http://+:5049;https://+:7040
  • ASPNETCORE_Kestrel__Certificates__Default__Password=P@ssw0rd123
  • ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/AccSol.pfx
  • PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/mssql-tools/bin

Dockerfile:

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
COPY --from=build /src/AccSol.API/certs /certs

ENV ASPNETCORE_ENVIRONMENT=DockerSql
ENV ASPNETCORE_URLS=http://+:5049;https://+:7040
ENV ASPNETCORE_Kestrel__Certificates__Default__Password=P@ssw0rd123
ENV ASPNETCORE_Kestrel__Certificates__Default__Path=/certs/AccSol.pfx

EXPOSE 5049
EXPOSE 7040
ENTRYPOINT [“dotnet”, “AccSol.API.dll”]

launchSettings.json file:

“DockerSql”: {
“commandName”: “Project”,
“launchBrowser”: true,
“launchUrl”: “swagger”,
“environmentVariables”: {
“ASPNETCORE_ENVIRONMENT”: “DockerSql”
},
“dotnetRunMessages”: true,
“applicationUrl”: “https://localhost:7040;http://localhost:5049
},

Here is my GitHub repository for this project if you’d like to test it on you end :wink:

GitHub - xmione/AccSol

And here is the associated issue item:

docker-compose file, Dockerfile and launchSettings.json file create many port bindings · Issue #8 · xmione/AccSol · GitHub

I have no problem creating only the two ports I want when I use docker run instead:

docker rmi -f accsol.api:latest

docker container rm -f accsol.api

docker system prune -f

docker build -t accsol.api -f AccSol.API\Dockerfile .

docker run --rm -p 5049:5049 -p 7040:7040 --name=accsol.api --network accsolnet -v ./certs:/certs accsol.api

Note: You can also run the above commands by running .\api.bat in the terminal.

Now, I have this problem when I run this command:

docker-compose --verbose up --build

Note: You can also run ./dup.bat and ./ddown.bat as a shortcut for running docker-compose up and down.

Have a look at the code in Github. Thanks in advance and Happy New Year!

Regards,
Sol

I was able to fix this finally by removing the docker-compose.override.yml and launchSettings.json in the Application’s root folder.