i have a dockerfile like this.
when i docker compose up the service, i can use command to view logs.
docker test -f logs
i want to copy the logs file to my local machine.
where is the path?
docker file
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build-env
WORKDIR /app
# Copy everything else and build
COPY ./ /app/
RUN dotnet restore -r linux-musl-x64 -s http://nexus.thedevcloud.net/repository/nuget-group/
RUN dotnet publish -r linux-musl-x64 -c Release -o DrugSync/out --no-restore
# Build runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
RUN apk add --no-cache icu-libs
ENV DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
ENV LC_ALL=en_US.UTF-8
ENV LANG=en_US.UTF-8
WORKDIR /app
COPY --from=build-env /app/test/out/ /app/
ENTRYPOINT ["/app/test"]
/var/lib/docker/containers/<container id>/<container id>-xxx.log
Where xxx stands for different formats based on how you have configured it.
docker inspect --format='{{.LogPath}}' $INSTANCE_ID
More details about configuring logging is here
EDIT:
$ docker inspect --format='{{.LogPath}}' 878eb2faac5c
/var/lib/docker/containers/878eb2faac5c9fe743fd9e9e6ba6ff7e0c3f1e02964df77e5a788dcd985c0d0b/878eb2faac5c9fe743fd9e9e6ba6ff7e0c3f1e02964df77e5a788dcd985c0d0b-json.log
Note:
On Mac machines this location would be on the VM hosting the docker containers and not on the MacOS Host.
Try screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty to access the location.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With