docker / for-mac

Bug reports for Docker Desktop for Mac
https://www.docker.com/products/docker#/mac
2.44k stars 118 forks source link

No container logs specified at LogPath #1996

Open freesoft opened 7 years ago

freesoft commented 7 years ago

Expected behavior

When docker inspect for running container, I'm expecting a log file (json-format by default) to be located at wherever "logPath" in docker inspect result.

Actual behavior

However, Docker for Mac does not create a directory and files. It's like /var/lib/docker/containers/, but there is no /var/lib/docker directory and/or its subdirectory containers. Even if I create /var/lib/docker/containers and run docker container, it does NOT log anything or create log file.

Information

Steps to reproduce the behavior

  1. docker run
  2. docker inspect against the running container (at step 1)
  3. find "LogPath" property and see if log file is created and/or writing a log in the file.
freesoft commented 7 years ago

Not sure if it's correct way or relevant, but when I ran screen command something like

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

and then cd /var/lib/docker/containers/

and checked the files, it has log file. However, --max-file and --max-size option doesn't work and the size of log file is keep increasing.

freesoft commented 7 years ago

It does create log file and rotate it with given size if I run it with docker-compose. Still original command doesn't work with "docker run" + file configuration in Docker for Mac preference configuration.

docker-robott commented 6 years ago

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale comment. Stale issues will be closed after an additional 30d of inactivity.

Prevent issues from auto-closing with an /lifecycle frozen comment.

If this issue is safe to close now please do so.

Send feedback to Docker Community Slack channels #docker-for-mac or #docker-for-windows. /lifecycle stale

bygui86 commented 6 years ago

/remove-lifecycle stale

bygui86 commented 6 years ago

/lifecycle frozen

bygui86 commented 6 years ago

If I would like to send logs to ElasticStack using FileBeat, what should I do? How should I configure everything?

mremi commented 6 years ago

Hi, any update about the last comment?

pavlo commented 6 years ago

Hi, I encountered the same problem - looking for a way getting the logs processed by FileBeat (ELK stack) - how do I do that on a Mac?

Thanks!

mremi commented 6 years ago

Hi, it works using a volume on /var/lib/docker/containers, in a docker-compose file it looks like:

filebeat:
    image: docker.elastic.co/beats/filebeat:6.3.1
    user: root
    volumes:
      - /var/lib/docker/containers:/mnt/log/containers:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro

BTW I also mounted /var/run/docker.sock to configure the Docker autodiscover provider.

Hope it will help you.

pengisgood commented 5 years ago

Any updates for getting docker container logs processed by filebeat on Mac?

iamyojimbo commented 5 years ago

Any updates for getting docker container logs processed by filebeat on Mac?

See the comment by @mremi. It works!

jeff-cook commented 5 years ago

See the comment by @mremi. It works!

That only works if there are log files in the folder. I think the main issue is there are no log files in that folder. For me the /var/lib/docker/containers folder doesn't even exist.

aakashpawar commented 5 years ago

any updates to the original issue ? "/var/lib/docker/containers folder doesn't even exist. ". I am running docker Linux containers in Win 10.

mremi commented 5 years ago

You can see it after getting a shell to the VM like this for instance:

screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty

linuxkit-025000000001:~# ls -lsa /var/lib/docker/containers
total 24
    16 drwx------    3 root     root         16384 Feb  4 09:30 .
     4 drwx--x--x   15 root     root          4096 Apr 18 12:57 ..
     4 drwx------    5 root     root          4096 Apr 18 12:57 0ab1ed1132dcdcc4441a84942dc6b634cbbccf28a26e6e432b6f5c04a230e6bc
wscourge commented 1 year ago

4 years later, still happens on Apple M1

image
 ~/ docker inspect --format="{{.LogPath}}" hix-cms                                                            12s
/var/lib/docker/containers/16c69bf170c30ced73bf5541159fea687a54d40c3a4ece6b1e1d8bff08682774/16c69bf170c30ced73bf5541159fea687a54d40c3a4ece6b1e1d8bff08682774-json.log
 ~/ ls -altrh /var/lib/                                                                                        0s
total 0
drwx------   2 _postfix  wheel    64B Oct 13 08:06 postfix
drwxr-xr-x   3 root      wheel    96B Oct 13 08:06 .
drwxr-xr-x  34 root      wheel   1.1K Mar 14 12:41 ..

image

Please, fix it.