3

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"]
tgogos
  • 23,218
  • 20
  • 96
  • 128
user2201789
  • 1,083
  • 2
  • 20
  • 45

1 Answers1

2
  • Log files can be found at:

/var/lib/docker/containers/<container id>/<container id>-xxx.log

Where xxx stands for different formats based on how you have configured it.

  • You can docker inspect each container to see where their logs are:

docker inspect --format='{{.LogPath}}' $INSTANCE_ID

More details about configuring logging is here

EDIT:

  • Similar question here
  • Also I tried it on mine at it shows up:

$ 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.

J. Scott Elblein
  • 4,013
  • 15
  • 58
  • 94
John Eipe
  • 10,922
  • 24
  • 72
  • 114