{"id":24695,"date":"2019-08-14T12:15:31","date_gmt":"2019-08-14T09:15:31","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=24695"},"modified":"2019-08-13T11:10:00","modified_gmt":"2019-08-13T08:10:00","slug":"debug-container-overriding-command","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/","title":{"rendered":"Debug your container by overriding the command"},"content":{"rendered":"\n<p>The main problem with docker on debugging has to do with images that already have the CMD command specified.<\/p>\n\n\n\n<p>If something goes wrong and has to do with the filesystem, or some commands that should have taken effect and they did not you need to do some troubleshooting.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" width=\"297\" height=\"77\" src=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2019\/08\/dockerimage-1.png\" alt=\"\" class=\"wp-image-24707\"\/><\/figure><\/div>\n\n\n\n<p>Overriding the command which is executed should be helpful. I do this all the time on custom images since I need some bash in order to be able to troubleshoot.<\/p>\n\n\n\n<p>Supposing I need to troubleshoot something on the default nginx image.<\/p>\n\n\n\n<p>Then nginx image should run like this.<\/p>\n\n\n\n<div>\n<div id=\"highlighter_833977\" class=\"syntaxhighlighter  bash\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"bash plain\">docker run --<\/code><code class=\"bash functions\">rm<\/code> <code class=\"bash plain\">nginx<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>Now instead of running our server, we shall override the command with a bash session (enter a shell by executing \/bin\/sh).<\/p>\n\n\n\n<div>\n<div id=\"highlighter_457508\" class=\"syntaxhighlighter  bash\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"bash plain\">docker run --<\/code><code class=\"bash functions\">rm<\/code> <code class=\"bash plain\">-it --entrypoint <\/code><code class=\"bash string\">\"\/bin\/sh\"<\/code> <code class=\"bash plain\">nginx<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<p>If you also want to pass arguments to the executable specified there is also another workaround.<\/p>\n\n\n\n<div>\n<div id=\"highlighter_889227\" class=\"syntaxhighlighter  bash\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">1<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"bash plain\">docker run --<\/code><code class=\"bash functions\">rm<\/code> <code class=\"bash plain\">-it --entrypoint <\/code><code class=\"bash string\">\"ls\"<\/code> <code class=\"bash plain\">nginx -l<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n\n\n\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Web Code Geeks with permission by Emmanouil Gkatziouras, partner at our <a href=\"\/\/www.webcodegeeks.com\/join-us\/wcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">WCG program<\/a>. See the original article here: <a href=\"https:\/\/egkatzioura.com\/2019\/08\/12\/debug-your-container-by-overriding-the-command\/\" target=\"_blank\" rel=\"noopener noreferrer\">Debug your container by overriding the command.<\/a><\/p>\n<p>Opinions expressed by Web Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>The main problem with docker on debugging has to do with images that already have the CMD command specified. If something goes wrong and has to do with the filesystem, or some commands that should have taken effect and they did not you need to do some troubleshooting. Overriding the command which is executed should &hellip;<\/p>\n","protected":false},"author":99,"featured_media":10356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[567,217],"class_list":["post-24695","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-container","tag-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Debug your container by overriding the command - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Debug your container by overriding the command - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-08-14T09:15:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Emmanouil Gkatziouras\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Emmanouil Gkatziouras\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\"},\"author\":{\"name\":\"Emmanouil Gkatziouras\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f242ded62465cfd1f8f091603351ba96\"},\"headline\":\"Debug your container by overriding the command\",\"datePublished\":\"2019-08-14T09:15:31+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\"},\"wordCount\":178,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"keywords\":[\"container\",\"Docker\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\",\"name\":\"Debug your container by overriding the command - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2019-08-14T09:15:31+00:00\",\"description\":\"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"DevOps\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/devops\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Debug your container by overriding the command\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f242ded62465cfd1f8f091603351ba96\",\"name\":\"Emmanouil Gkatziouras\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g\",\"caption\":\"Emmanouil Gkatziouras\"},\"description\":\"He is a versatile software engineer with experience in a wide variety of applications\/services.He is enthusiastic about new projects, embracing new technologies, and getting to know people in the field of software.\",\"sameAs\":[\"http:\/\/egkatzioura.wordpress.com\/\",\"https:\/\/gr.linkedin.com\/in\/gkatziourasemmanouil\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/emmanouil-gkatziouras\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Debug your container by overriding the command - Web Code Geeks - 2026","description":"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/","og_locale":"en_US","og_type":"article","og_title":"Debug your container by overriding the command - Web Code Geeks - 2026","og_description":"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command","og_url":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2019-08-14T09:15:31+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","type":"image\/jpeg"}],"author":"Emmanouil Gkatziouras","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Emmanouil Gkatziouras","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/"},"author":{"name":"Emmanouil Gkatziouras","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f242ded62465cfd1f8f091603351ba96"},"headline":"Debug your container by overriding the command","datePublished":"2019-08-14T09:15:31+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/"},"wordCount":178,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","keywords":["container","Docker"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/","url":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/","name":"Debug your container by overriding the command - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2019-08-14T09:15:31+00:00","description":"Interested to learn about docker on debugging? Check our article explaining how to debug your container with docker by overriding the command","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/devops\/debug-container-overriding-command\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"DevOps","item":"https:\/\/www.webcodegeeks.com\/category\/devops\/"},{"@type":"ListItem","position":3,"name":"Debug your container by overriding the command"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/f242ded62465cfd1f8f091603351ba96","name":"Emmanouil Gkatziouras","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/5c6d031d211ab786ec335687ad6f3f076f93f47e24c92d78041d2f805ee6c291?s=96&d=mm&r=g","caption":"Emmanouil Gkatziouras"},"description":"He is a versatile software engineer with experience in a wide variety of applications\/services.He is enthusiastic about new projects, embracing new technologies, and getting to know people in the field of software.","sameAs":["http:\/\/egkatzioura.wordpress.com\/","https:\/\/gr.linkedin.com\/in\/gkatziourasemmanouil"],"url":"https:\/\/www.webcodegeeks.com\/author\/emmanouil-gkatziouras\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24695","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/99"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=24695"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/24695\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/10356"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=24695"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=24695"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=24695"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}