I am learning docker with asp.net core. Create a mvc application, dockerfile and docker-compose.yml file. I have docker file as below:
FROM mcr.microsoft.com/dotnet/sdk:7.0 as debug
#install debugger for NET Core
RUN apt-get update
RUN apt-get install -y unzip
RUN curl -sSL https://aka.ms/getvsdbgsh | /bin/sh /dev/stdin -v latest -l ~/vsdbg
RUN mkdir /app/
WORKDIR /app/
COPY ./src/testapp.csproj /app/testapp.csproj
RUN dotnet restore
COPY ./src/ /app/
RUN mkdir /out/
RUN dotnet publish --no-restore --output /out/ --configuration Release
EXPOSE 80
CMD dotnet run --urls "http://0.0.0.0:80"
Also, I have docker compose file as below:
version: "3.0"
services:
db:
image: postgres
restart: always
ports:
- "5432"
volumes:
- postgres:/var/lib/postgresql/data
environment:
POSTGRES_PASSWORD: password
POSTGRES_USER: sachin
pg_admin:
image: dpage/pgadmin4
restart: always
ports:
- "5555:80"
volumes:
- pg_admin:/var/lib/pgadmin
environment:
PGADMIN_DEFAULT_EMAIL: sachin.maharjan@dishhome.com.np
PGADMIN_DEFAULT_PASSWORD: password
web:
container_name: csharp
build:
context: .
target: debug
ports:
- "5000:80"
volumes:
- ./src:/app/
depends_on:
- db
volumes:
postgres:
pg_admin:
I have installed docker extension and C# extension in my vs code. I have lunch.js file inside.vscode folder.
The content of lunch.js:
{
"version": "0.2.0",
"configurations": [
{
"name": ".NET Core Docker Attach",
"type": "coreclr",
"request": "attach",
"processId": "${command:pickRemoteProcess}",
"pipeTransport": {
"pipeProgram": "docker",
"pipeArgs": [ "exec", "-i", "csharp" ],
"debuggerPath": "/root/vsdbg/vsdbg",
"pipeCwd": "${workspaceRoot}",
"quoteArgs": false
},
"sourceFileMap": {
"/work": "${workspaceRoot}/src/"
}
},
]
}
The debugger stop at break point but it shows error like this.
Is this error with volume mapping or did I set up lunch.json wrong?
I noticed in lunch.json in the source map section, I mapped the wrong folder in local file system with file system with docker. Previously, MapSetting section was like below:
"sourceFileMap":
{
"/work": "${workspaceRoot}/src/"
}
Then I change folder mapping with right one and erorr is solved.
"sourceFileMap": {
"/src": "${workspaceRoot}/src/"
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.