{"id":5434,"date":"2018-10-09T01:45:23","date_gmt":"2018-10-09T01:45:23","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=5434"},"modified":"2021-11-17T09:51:59","modified_gmt":"2021-11-17T09:51:59","slug":"how-to-troubleshoot-docker-serverdaemon-and-containers","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/how-to-troubleshoot-docker-serverdaemon-and-containers\/","title":{"rendered":"How to troubleshoot Docker Server(daemon) and Containers?"},"content":{"rendered":"<p><strong>How to troubleshoot Docker Server(daemon) and Containers?<\/strong><\/p>\n<p>There are following way using troubleshooting of Docker Server and Containers can be done. If you are running your container in -d (detached mode) or by docker remote API, you will not see any logs in console. To access running docker image or container logs you need to use docker logs command.<\/p>\n<h3><strong>Docker Containers Logs<\/strong><\/h3>\n<p><strong>The docker logs command shows information logged by a running container.<\/strong><\/p>\n<p>[code]$ docker logs cont-id<br>\n$ docker container logs cont-id<br>\n$ docker logs &#8211;details CONTAINER<br>\n$ docker logs [OPTIONS] CONTAINER<br>\n$ docker container logs [OPTIONS] CONTAINER<br>\n$ docker help logs<br>\n# To follow docker log output or tail continuously<br>\n$ docker logs &#8211;follow ContainerName\/ContainerID<\/p>\n<p># To see last n lines of logs<br>\n$ docker logs &#8211;tail 2500 ContainerName\/ContainerID<\/p>\n<p># To see logs since particular date or timestamp<br>\n$ docker logs &#8211;since 2017-05-03 ContainerName\/ContainerID[\/code]<\/p>\n<p><strong>The docker service logs command shows information logged by all containers participating in a service.<\/strong><\/p>\n<p>[code]$ docker service logs[\/code]<\/p>\n<ul>\n<li>If you use a logging driver which sends logs to a file, an external host, a database, or another logging back-end, docker logs may not show useful information.<\/li>\n<li>If your image runs a non-interactive process such as a web server or a database, that application may send its output to log files instead of STDOUT and STDERR.<\/li>\n<\/ul>\n<h3><strong>Docker Events from Docker Server<\/strong><\/h3>\n<p>To get real time events from the server, we can docker events commands. Information can include historical information and real-time information.<\/p>\n<p>[code]$ docker events[\/code]<\/p>\n<p><strong>Docker containers will report the following events:<\/strong><br>\nattach, commit, copy, create, destroy, detach, die, exec_create, exec_detach, exec_start, export, kill, oom, pause, rename, resize, restart, start, stop, top, unpause, update<\/p>\n<p><strong>Docker images report the following events:<\/strong><br>\ndelete, import, load, pull, push, save, tag, untag<\/p>\n<p><strong>Docker volumes report the following events:<\/strong><br>\ncreate, mount, unmount, destroy<\/p>\n<p><strong>Docker networks report the following events:<\/strong><br>\ncreate, connect, disconnect, destroy<\/p>\n<h3>Docker Daemon Logs<\/h3>\n<p>Docker daemon log depends on your OS. Here are the few locations, with commands for few Operating Systems:<\/p>\n<ul>\n<li>Ubuntu (old using upstart ) &#8211; \/var\/log\/upstart\/docker.log<\/li>\n<li>Ubuntu (new using systemd ) &#8211; sudo journalctl -fu docker.service<\/li>\n<li>Boot2Docker &#8211; \/var\/log\/docker.log<\/li>\n<li>Debian GNU\/Linux &#8211; \/var\/log\/daemon.log<\/li>\n<li>CentOS &#8211; \/var\/log\/daemon.log | grep docker<\/li>\n<li>CoreOS &#8211; journalctl -u docker.service<\/li>\n<li>Fedora &#8211; journalctl -u docker.service<\/li>\n<li>Red Hat Enterprise Linux Server &#8211; \/var\/log\/messages | grep docker<\/li>\n<li>OpenSuSE &#8211; journalctl -u docker.service<\/li>\n<li>OSX &#8211; ~\/Library\/Containers\/com.docker.docker\/Data\/com.docker.driver.amd64-linux\/log\/d\u200c\u200bocker.log<\/li>\n<li>Windows &#8211; Get-EventLog -LogName Application -Source Docker -After (Get-Date).AddMinutes(-5) | Sort-Object Time<\/li>\n<\/ul>\n<p><strong>If your OS is using systemd then you can view docker daemon log with:<\/strong><br>\n$ sudo journalctl -fu docker.service<\/p>\n<p><strong>Using CentOS7, logs are available using the command<\/strong><br>\n$ journalctl -u docker<\/p>\n<p><strong>For Docker Mac Native (without Boot2Docker or docker-machine, running your Docker installation without extra VirtualBox<\/strong><br>\n$ syslog -k Sender Docker<\/p>\n<p><strong>Docker for Mac (Beta)<\/strong><br>\n~\/Library\/Containers\/com.docker.docker\/Data\/com.docker.driver.amd64-linux\/log\/d\u200c\u200bocker.log<\/p>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_98973\"><figure class=\"wp-block-embed wp-block-embed-youtube is-type-video is-provider-youtube epyt-figure\"><div class=\"wp-block-embed__wrapper\"><iframe loading=\"lazy\"  id=\"_ytid_66181\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_98973\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><\/div><\/figure><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>How to troubleshoot Docker Server(daemon) and Containers? There are following way using troubleshooting of Docker Server and Containers can be done. If you are running your container in -d (detached mode) or by docker remote API, you will not see any logs in console. To access running docker image or container logs you need to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":8064,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","_joinchat":[],"footnotes":""},"categories":[4862],"tags":[1186,470,567,5085,603,399,250,1795],"class_list":["post-5434","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-docker","tag-containers","tag-daemon","tag-docker","tag-events","tag-logs","tag-server","tag-service","tag-troubleshoot"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5434","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=5434"}],"version-history":[{"count":3,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5434\/revisions"}],"predecessor-version":[{"id":25574,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/5434\/revisions\/25574"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/8064"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=5434"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=5434"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=5434"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}