#FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
FROM microsoft/dotnet:2.1-aspnetcore-runtime-alpine AS base
WORKDIR /app
EXPOSE 51132
EXPOSE 44351
#FROM microsoft/dotnet:2.1-sdk AS build
FROM microsoft/dotnet:2.1-sdk-alpine AS build
WORKDIR /src
COPY testcore21docker/testcore21docker.csproj testcore21docker/
RUN dotnet restore testcore21docker/testcore21docker.csproj
COPY . .
WORKDIR /src/testcore21docker
RUN dotnet build testcore21docker.csproj -c Release -o /app
FROM build AS publish
RUN dotnet publish testcore21docker.csproj -c Release -o /app
FROM base AS final
WORKDIR /app
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "testcore21docker.dll"]
The API runs and returns a result.
A build error:
1>------ Build started: Project: docker-compose, Configuration: Debug Any CPU ------
1>docker ps --filter "status=running" --filter "name=dockercompose4649805194979931907_testcore21docker_" --format {{.ID}} -n 1
1>4f382e56f1d7
1>docker exec -i 4f382e56f1d7 /bin/bash -c "if PID=$(pidof -x dotnet); then kill $PID; fi"
1>OCI runtime exec failed: exec failed: container_linux.go:348: starting container process caused "exec: \"/bin/bash\": stat /bin/bash: no such file or directory": unknown
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(311,5): error : .
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(311,5): error :
1>C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Sdks\Microsoft.Docker.Sdk\build\Microsoft.VisualStudio.Docker.Compose.targets(311,5): error : For more troubleshooting information, go to http://aka.ms/DockerToolsTroubleshooting
1>Done building project "docker-compose.dcproj" -- FAILED.
========== Build: 0 succeeded or up-to-date, 1 failed, 0 skipped ==========
If I comment the alpine lines, uncomment the original lines and build, the problem remains.
If I restart VS with the original lines, the behavior is again as expected.
Apparently debugger support for Alpine is still a work in progress, but there currently is no bug, follow-up and progress available: https://developercommunity.visualstudio.com/content/problem/256756/new-container-tools-in-158-cant-debug-alpine-docke.html
docker versionClient:
Version: 18.03.1-ce
API version: 1.37
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:12:48 2018
OS/Arch: windows/amd64
Experimental: false
Orchestrator: swarm
Server:
Engine:
Version: 18.03.1-ce
API version: 1.37 (minimum version 1.12)
Go version: go1.9.5
Git commit: 9ee9f40
Built: Thu Apr 26 07:22:38 2018
OS/Arch: linux/amd64
Experimental: false
docker infoContainers: 12
Running: 2
Paused: 0
Stopped: 10
Images: 64
Server Version: 18.03.1-ce
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 773c489c9c1b21a6d78b5c538cd395416ec50f88
runc version: 4fc53a81fb7c994640722ac585fa9ca548971871
init version: 949e6fa
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.87-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 2
Total Memory: 1.934GiB
Name: linuxkit-00155d0dd701
ID: O4CH:Y6PE:TUJ2:N3XC:UYYJ:REUP:F43Q:XOH7:VHJI:27HC:LKM2:R4AW
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 35
Goroutines: 48
System Time: 2018-07-03T13:10:16.2043418Z
EventsListeners: 1
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
Hi @jeroenwo,
Thanks for reporting this. We do not officially support alpine images with Docker tools in VS at the moment, and as you mentioned there's still work in progress with regards to debugging as well.
However, as a workaround to get your project to build and run (without debugging), you can install bash in the dockerfile by adding this: RUN apk add --no-cache bash since the tooling depends on it.
I also encountered this issue when using the alpine based images and used the workaround suggested by @haniamr, however I now see there is another error in the use of pidof.
docker exec -i f2b10292c51d /bin/bash -c "if PID=$(pidof -x dotnet); then kill $PID; fi"
pidof: unrecognized option: x
BusyBox v1.27.2 (2018-06-06 09:08:44 UTC) multi-call binary.
Usage: pidof [OPTIONS] [NAME]...
List PIDs of all processes with names that match NAMEs
-s Show only one PID
-o PID Omit given pid
Use %PPID to omit pid of pidof's parent
@msnelling thanks for reporting that, it's definitely helpful to know what areas we need to work on to fully support Alpine-based images. The task is in our backlog and I'll update this issue here whenever the changes become ready.
any progress or workarounds on this?
Seems to be working now? As of Microsoft.VisualStudio.Azure.Containers.Tools.Targets 1.4.2, my kill command is now
docker exec -i [img] /bin/sh -c "if PID=$(pidof dotnet); then kill $PID; fi"
Which works with the alpine images :)
@JoshSchreuder Yes, we have begun making some of the needed changes to support Alpine, including that change to the kill command. Beginning in VS 2019 Preview 3, which will release soon, we'll also have the changes needed to use the correct debugger for Alpine images. It is also necessary to upgrade your package reference to Microsoft.VisualStudio.Azure.Containers.Tools.Targets to version 1.4.4. You can see this Developer Community issue for more information: https://developercommunity.visualstudio.com/content/problem/256756/new-container-tools-in-158-cant-debug-alpine-docke.html
I'm marking this fixed now since VS2019 Preview 3 should be available very soon. You can view some more information about how to use the features in the solution for the Developer Community ticket.
I'm linking some steps that may work for VS2017 although they are not guaranteed (and it is not officially supported): https://github.com/Microsoft/DockerTools/issues/179#issuecomment-482178661
Most helpful comment
@JoshSchreuder Yes, we have begun making some of the needed changes to support Alpine, including that change to the kill command. Beginning in VS 2019 Preview 3, which will release soon, we'll also have the changes needed to use the correct debugger for Alpine images. It is also necessary to upgrade your package reference to Microsoft.VisualStudio.Azure.Containers.Tools.Targets to version 1.4.4. You can see this Developer Community issue for more information: https://developercommunity.visualstudio.com/content/problem/256756/new-container-tools-in-158-cant-debug-alpine-docke.html