{"id":35552,"date":"2023-05-23T04:27:54","date_gmt":"2023-05-23T04:27:54","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=35552"},"modified":"2025-07-12T05:40:13","modified_gmt":"2025-07-12T05:40:13","slug":"debug-for-docker-container","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/debug-for-docker-container\/","title":{"rendered":"Debug for Docker Container"},"content":{"rendered":"\n<p>Please follow below steps to Debug Docker container:<\/p>\n\n\n\n<p>1. Check the logs of the MongoDB container:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">docker logs mongodb<\/code><\/span><\/pre>\n\n\n<p>This command will display the logs generated by the MongoDB container. Check if there are any errors or warnings related to the MongoDB startup or connection.<\/p>\n\n\n\n<p>2. Verify the MongoDB container&#8217;s network configuration:<\/p>\n\n\n\n<p>Run the following command to inspect the MongoDB container&#8217;s network settings:<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">docker inspect mongodb<\/code><\/span><\/pre>\n\n\n<p>Look for the &#8220;Networks&#8221; section in the output. Ensure that the container is connected to a network, and note the network name.<\/p>\n\n\n\n<p>3. Test connectivity to the MongoDB container:<\/p>\n\n\n\n<p>Run the following command to start a temporary container in the same network as the MongoDB container:<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">docker run -it --rm --network= mongo mongo --host mongodb --<span class=\"hljs-keyword\">eval<\/span> <span class=\"hljs-string\">\"printjson(db.serverStatus()\n<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p>Replace <code>&lt;network-name&gt;<\/code> with the actual network name from the previous step.<\/p>\n\n\n\n<p>If the command is successful, it means you can connect to the MongoDB container from within the same network.<\/p>\n\n\n\n<p>or find network name by below command<\/p>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">docker network ls<\/code><\/span><\/pre>\n\n\n<p><\/p>\n\n\n\n<p>If the issue persists, please provide the complete error message and the outputs of the commands <code>docker ps<\/code>, <code>docker inspect mongodb<\/code>, and <code>docker logs mongodb<\/code>. This will help in further diagnosing the problem.<\/p>\n\n\n\n<p><br><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Please follow below steps to Debug Docker container: 1. Check the logs of the MongoDB container: This command will display the logs generated by the MongoDB container. Check if there&#8230; <\/p>\n","protected":false},"author":48,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[4862],"tags":[],"class_list":["post-35552","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/35552","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\/48"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=35552"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/35552\/revisions"}],"predecessor-version":[{"id":35554,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/35552\/revisions\/35554"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=35552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=35552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=35552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}