Last active
June 28, 2024 08:49
-
-
Save megasuperlexa/6c8050065f99a4dd2f1c9157269d5018 to your computer and use it in GitHub Desktop.
Docker that extends existing .net app image with memory dump tools (Debian)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS tools-install | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-sos | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-trace | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-dump | |
RUN dotnet tool install --tool-path /dotnetcore-tools dotnet-counters | |
FROM {your-image-location-and-name:1.1.1-release-1.0.0} | |
USER 0 | |
RUN apt-get update \ | |
&& apt-get upgrade -y \ | |
&& apt-get install -y \ | |
file \ | |
lldb \ | |
wget \ | |
&& rm -rf /var/lib/apt/lists/* | |
RUN wget https://packages.microsoft.com/config/debian/12/packages-microsoft-prod.deb -O packages-microsoft-prod.deb | |
RUN dpkg -i packages-microsoft-prod.deb | |
RUN rm packages-microsoft-prod.deb | |
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh | |
RUN chmod +x ./dotnet-install.sh | |
RUN ./dotnet-install.sh --channel 8.0 --runtime dotnet | |
ENV PATH="/root/.dotnet:${PATH}" | |
ENV DOTNET_ROOT="/root/.dotnet" | |
COPY --from=tools-install /dotnetcore-tools /opt/dotnetcore-tools | |
ENV PATH="/opt/dotnetcore-tools:${PATH}" | |
RUN dotnet-sos install | |
# build and push new image: | |
# docker build --platform linux/amd64 -t {base-name:base-image-tag}-dump . | |
# docker tag {base-name:base-image-tag}-dump {registry-location}/{base-name:base-image-tag}-dump | |
# docker push {registry-location}/{base-name:base-image-tag}-dump | |
# usage inside container: | |
# dotnet-dump ps | |
# dotnet-counters monitor -p {process-id} | |
# dotnet-dump collect -p {process_id} -o ./coredump.{process_id} | |
# dotnet-dump analyze ./coredump.{process_id} | |
# inside the tool: | |
# dumpheap -stat | |
# dumpheap -type | |
# gcroot {address} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment