{"id":17521,"date":"2017-06-22T12:15:07","date_gmt":"2017-06-22T09:15:07","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=17521"},"modified":"2017-06-22T10:37:08","modified_gmt":"2017-06-22T07:37:08","slug":"understanding-dockers-cmd-entrypoint-instructions","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/","title":{"rendered":"Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions"},"content":{"rendered":"<p>When creating a Docker container, the goal is generally that anyone could simply execute <code>docker run &lt;containername&gt;<\/code> and launch the container. In today\u2019s article, we are going to explore two key <code>Dockerfile<\/code> instructions that enable us to do just that. Let\u2019s explore the differences between the <code>CMD<\/code> and <code>ENTRYPOINT<\/code> instructions.<\/p>\n<p>On the surface, the <code>CMD<\/code> and <code>ENTRYPOINT<\/code> instructions look like they perform the same function. However, once you dig deeper, it\u2019s easy to see that these two instructions perform completely different tasks.<\/p>\n<h2>ApacheBench <code>Dockerfile<\/code><\/h2>\n<p>To help serve as an example, we\u2019re going to create a Docker container that simply executes the ApacheBench utility.<\/p>\n<p>In <a href=\"https:\/\/blog.codeship.com\/tuning-nginx\/\">earlier articles<\/a>, we discovered the simplicity and usefulness of the ApacheBench load testing tool. However, this type of command-line utility is not generally the type of application one would \u201cDockerize.\u201d The general usage of Docker is focused more on creating services rather than single execution tools like ApacheBench.<\/p>\n<p>The main reason behind this is that typically Docker containers are not built to accept additional parameters when launching. This makes it tricky to use a command-line tool within a container.<\/p>\n<p>Let\u2019s see this in action by creating a Docker container that can be used to execute ApacheBench against any site.<\/p>\n<pre class=\"brush:php\">FROM ubuntu:latest\r\n\r\nRUN apt-get update &amp;&amp; \\\r\n    apt-get install -y apache2-utils &amp;&amp; \\\r\n    rm -rf \/var\/lib\/apt\/lists\/*\r\n\r\nCMD ab<\/pre>\n<p>In the <code>Dockerfile<\/code>, we are simply using the <code>ubuntu:latest<\/code> image as our base container image, installing the <code>apache2-utils<\/code> package, and then defining that the command for this container is the <code>ab<\/code> command.<\/p>\n<p>Since this Docker container is planned to be used as an executor for the <code>ab<\/code> command, it makes sense to set the <code>CMD<\/code> instruction value to the <code>ab<\/code> command. However, if we run this container we will start to see an interesting difference between this container and other application containers.<\/p>\n<p>Before we can run this container, however, we first need to build it. We can do so with the <code>docker build<\/code> command.<\/p>\n<pre class=\"brush:php\">$ docker build -t ab .\r\nSending build context to Docker daemon 2.048 kB\r\nStep 1\/3 : FROM ubuntu:latest\r\n ---&gt; ebcd9d4fca80\r\nStep 2\/3 : RUN apt-get update &amp;&amp;     apt-get install -y apache2-utils &amp;&amp;     rm -rf \/var\/lib\/apt\/lists\/*\r\n ---&gt; Using cache\r\n ---&gt; d9304ff09c98\r\nStep 3\/3 : CMD ab\r\n ---&gt; Using cache\r\n ---&gt; ecfc71e7fba9\r\nSuccessfully built ecfc71e7fba9<\/pre>\n<p>When building this container, I tagged the container with the name of <code>ab<\/code>. This means we can simply launch this container via the name <code>ab<\/code>.<\/p>\n<pre class=\"brush:php\">$ docker run ab\r\nab: wrong number of arguments\r\nUsage: ab [options] [http[s]:\/\/]hostname[:port]\/path\r\nOptions are:\r\n    -n requests     Number of requests to perform\r\n    -c concurrency  Number of multiple requests to make at a time\r\n    -t timelimit    Seconds to max. to spend on benchmarking\r\n                    This implies -n 50000\r\n    -s timeout      Seconds to max. wait for each response\r\n                    Default is 30 seconds<\/pre>\n<p>When we run the <code>ab<\/code> container, we get back an error from the <code>ab<\/code> command as well as usage details. The reason for this is that we defined the <code>CMD<\/code> instruction to the <code>ab<\/code> command without specifying any flags or target host to load test against. This <code>CMD<\/code> instruction is used to define what command the container should execute when launched. Since we defined that as the <code>ab<\/code> command without arguments, it executed the <code>ab<\/code> command without arguments.<\/p>\n<p>However, like most command-line tools, that simply isn\u2019t how <code>ab<\/code> works. With <code>ab<\/code>, you need to specify what <code>URL<\/code> you wish to test against.<\/p>\n<p>What we can do in order to make this work is <strong>override<\/strong> the <code>CMD<\/code> instruction when we launch the container. We can do this by adding the command and arguments we wish to execute at the end of the <code>docker run<\/code> command.<\/p>\n<pre class=\"brush:php\">$ docker run ab ab http:\/\/bencane.com\/\r\nBenchmarking bencane.com (be patient).....done\r\nConcurrency Level:      1\r\nTime taken for tests:   0.343 seconds\r\nComplete requests:      1\r\nFailed requests:        0\r\nTotal transferred:      98505 bytes\r\nHTML transferred:       98138 bytes\r\nRequests per second:    2.92 [#\/sec] (mean)\r\nTime per request:       342.671 [ms] (mean)\r\nTime per request:       342.671 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          280.72 [Kbytes\/sec] received<\/pre>\n<p>When we add <code>ab http:\/\/bencane.com<\/code> to the end of our <code>docker run<\/code> command, we are able to override the <code>CMD<\/code> instruction and execute the <code>ab<\/code> command successfully. However, while we were successful, this process of overriding the <code>CMD<\/code> instruction is rather clunky.<\/p>\n<p>!Sign up for a free Codeship Account<\/p>\n<h2>ENTRYPOINT<\/h2>\n<p>This is where the <code>ENTRYPOINT<\/code> instruction shines. The <code>ENTRYPOINT<\/code> instruction works very similarly to <code>CMD<\/code> in that it is used to specify the command executed when the container is started. However, where it differs is that <code>ENTRYPOINT<\/code> doesn\u2019t allow you to override the command.<\/p>\n<p>Instead, anything added to the end of the <code>docker run<\/code> command is appended to the command. To understand this better, let\u2019s go ahead and change our <code>CMD<\/code> instruction to the <code>ENTRYPOINT<\/code> instruction.<\/p>\n<pre class=\"brush:php\">FROM ubuntu:latest\r\n\r\nRUN apt-get update &amp;&amp; \\\r\n    apt-get install -y apache2-utils &amp;&amp; \\\r\n    rm -rf \/var\/lib\/apt\/lists\/*\r\n\r\nENTRYPOINT [\"ab\"]<\/pre>\n<p>After editing the <code>Dockerfile<\/code>, we will need to build the image once again.<\/p>\n<pre class=\"brush:php\">$ docker build -t ab .\r\nSending build context to Docker daemon 2.048 kB\r\nStep 1\/3 : FROM ubuntu:latest\r\n ---&gt; ebcd9d4fca80\r\nStep 2\/3 : RUN apt-get update &amp;&amp;     apt-get install -y apache2-utils &amp;&amp;     rm -rf \/var\/lib\/apt\/lists\/*\r\n ---&gt; Using cache\r\n ---&gt; d9304ff09c98\r\nStep 3\/3 : ENTRYPOINT ab\r\n ---&gt; Using cache\r\n ---&gt; aa020cfe0708\r\nSuccessfully built aa020cfe0708<\/pre>\n<p>Now, we can run the <code>ab<\/code> container once again; however, this time, rather than specifying <code>ab http:\/\/bencane.com<\/code>, we can simply add <code>http:\/\/bencane.com<\/code> to the end of the <code>docker run<\/code> command.<\/p>\n<pre class=\"brush:php\">$ docker run ab http:\/\/bencane.com\/\r\nBenchmarking bencane.com (be patient).....done\r\nConcurrency Level:      1\r\nTime taken for tests:   0.436 seconds\r\nComplete requests:      1\r\nFailed requests:        0\r\nTotal transferred:      98505 bytes\r\nHTML transferred:       98138 bytes\r\nRequests per second:    2.29 [#\/sec] (mean)\r\nTime per request:       436.250 [ms] (mean)\r\nTime per request:       436.250 [ms] (mean, across all concurrent requests)\r\nTransfer rate:          220.51 [Kbytes\/sec] received<\/pre>\n<p>As the above example shows, we have now essentially turned our container into an executable. If we wanted, we could add additional flags to the <code>ENTRYPOINT<\/code> instruction to simplify a complex command-line tool into a single-argument Docker container.<\/p>\n<h3>Be careful with syntax<\/h3>\n<p>One imporant thing to call out about the <code>ENTRYPOINT<\/code> instruction is that syntax is critical. Technically, <code>ENTRYPOINT<\/code> supports both the <code>ENTRYPOINT [\"command\"]<\/code> syntax and the <code>ENTRYPOINT command<\/code> syntax. However, while both of these are supported, they have two different meanings and change how <code>ENTRYPOINT<\/code> works.<\/p>\n<p>Let\u2019s change our <code>Dockerfile<\/code> to match this syntax and see how it changes our containers behavior.<\/p>\n<pre class=\"brush:php\">FROM ubuntu:latest\r\n\r\nRUN apt-get update &amp;&amp; \\\r\n    apt-get install -y apache2-utils &amp;&amp; \\\r\n    rm -rf \/var\/lib\/apt\/lists\/*\r\n\r\nENTRYPOINT ab<\/pre>\n<p>With the changes made, let\u2019s build the container.<\/p>\n<pre class=\"brush:php\">$ docker build -t ab .\r\nSending build context to Docker daemon 2.048 kB\r\nStep 1\/3 : FROM ubuntu:latest\r\n ---&gt; ebcd9d4fca80\r\nStep 2\/3 : RUN apt-get update &amp;&amp;     apt-get install -y apache2-utils &amp;&amp;     rm -rf \/var\/lib\/apt\/lists\/*\r\n ---&gt; Using cache\r\n ---&gt; d9304ff09c98\r\nStep 3\/3 : ENTRYPOINT ab\r\n ---&gt; Using cache\r\n ---&gt; bbfe2686a064\r\nSuccessfully built bbfe2686a064<\/pre>\n<p>With the container built, let\u2019s run it again using the same options as before.<\/p>\n<pre class=\"brush:php\">$ docker run ab http:\/\/bencane.com\/\r\nab: wrong number of arguments\r\nUsage: ab [options] [http[s]:\/\/]hostname[:port]\/path\r\nOptions are:\r\n    -n requests     Number of requests to perform\r\n    -c concurrency  Number of multiple requests to make at a time\r\n    -t timelimit    Seconds to max. to spend on benchmarking\r\n                    This implies -n 50000\r\n    -s timeout      Seconds to max. wait for each response\r\n                    Default is 30 seconds<\/pre>\n<p>It looks like we are back to the same behavior as the <code>CMD<\/code> instruction. However, if we try to override the <code>ENTRYPOINT<\/code> we will see different behavior than when we overrode the <code>CMD<\/code> instruction.<\/p>\n<pre class=\"brush:php\">$ docker run ab ab http:\/\/bencane.com\/\r\nab: wrong number of arguments\r\nUsage: ab [options] [http[s]:\/\/]hostname[:port]\/path\r\nOptions are:\r\n    -n requests     Number of requests to perform\r\n    -c concurrency  Number of multiple requests to make at a time\r\n    -t timelimit    Seconds to max. to spend on benchmarking\r\n                    This implies -n 50000\r\n    -s timeout      Seconds to max. wait for each response\r\n                    Default is 30 seconds<\/pre>\n<p>With the <code>ENTRYPOINT<\/code> instruction, it is not possible to override the instruction during the <code>docker run<\/code> command execution like we are with <code>CMD<\/code>. This highlights another usage of <code>ENTRYPOINT<\/code>, as a method of ensuring that a specific command is executed when the container in question is started regardless of attempts to override the <code>ENTRYPOINT<\/code>.<\/p>\n<h2>Summary<\/h2>\n<p>In this article, we covered quite a bit about <code>CMD<\/code> and <code>ENTRYPOINT<\/code>; however, there are still additional uses of these two instructions that allow you to customize how a Docker container starts. To see some of these examples, you can take a look at Docker\u2019s <code>Dockerfile<\/code> <a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/#entrypoint\">reference docs<\/a>.<\/p>\n<p>With the above example however, we now have a way to \u201cDockerize\u201d simple command-line tools such as <code>ab<\/code>, which opens up quite a few interesting use cases. If you have one, feel free to share it in the comments below.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"https:\/\/blog.codeship.com\/understanding-dockers-cmd-and-entrypoint-instructions\/\">Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Ben Cane at the <a href=\"http:\/\/blog.codeship.com\/\">Codeship Blog<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In today\u2019s article, we are going to explore two key Dockerfile instructions that enable us to do just that. Let\u2019s explore the differences between the CMD and ENTRYPOINT instructions. On the surface, the CMD &hellip;<\/p>\n","protected":false},"author":158,"featured_media":10356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17],"tags":[217],"class_list":["post-17521","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-devops","tag-docker"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Understanding Docker&#039;s CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In\" \/>\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\/understanding-dockers-cmd-entrypoint-instructions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Understanding Docker&#039;s CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\" \/>\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=\"2017-06-22T09:15:07+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=\"Benjamin Cane\" \/>\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=\"Benjamin Cane\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"8 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\"},\"author\":{\"name\":\"Benjamin Cane\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4f5d918df9c19fab91b5b205357ce0b8\"},\"headline\":\"Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions\",\"datePublished\":\"2017-06-22T09:15:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\"},\"wordCount\":908,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"keywords\":[\"Docker\"],\"articleSection\":[\"DevOps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\",\"name\":\"Understanding Docker's CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2017-06-22T09:15:07+00:00\",\"description\":\"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#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\/understanding-dockers-cmd-entrypoint-instructions\/#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\":\"Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions\"}]},{\"@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\/4f5d918df9c19fab91b5b205357ce0b8\",\"name\":\"Benjamin Cane\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/09c6af2f1a7430456089189937094b817ef1b7c75ab9968bfd3ec35d938d914b?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/09c6af2f1a7430456089189937094b817ef1b7c75ab9968bfd3ec35d938d914b?s=96&d=mm&r=g\",\"caption\":\"Benjamin Cane\"},\"description\":\"Benjamin Cane is a systems architect in the financial services industry. He writes about Linux systems administration on his blog and has recently published his first book, Red Hat Enterprise Linux Troubleshooting Guide.\",\"url\":\"https:\/\/www.webcodegeeks.com\/author\/benjamin-cane\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Understanding Docker's CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026","description":"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In","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\/understanding-dockers-cmd-entrypoint-instructions\/","og_locale":"en_US","og_type":"article","og_title":"Understanding Docker's CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026","og_description":"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In","og_url":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-06-22T09:15:07+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":"Benjamin Cane","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Benjamin Cane","Est. reading time":"8 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/"},"author":{"name":"Benjamin Cane","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4f5d918df9c19fab91b5b205357ce0b8"},"headline":"Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions","datePublished":"2017-06-22T09:15:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/"},"wordCount":908,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","keywords":["Docker"],"articleSection":["DevOps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/","url":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/","name":"Understanding Docker's CMD and ENTRYPOINT Instructions - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2017-06-22T09:15:07+00:00","description":"When creating a Docker container, the goal is generally that anyone could simply execute docker run &lt;containername&gt; and launch the container. In","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/devops\/understanding-dockers-cmd-entrypoint-instructions\/#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\/understanding-dockers-cmd-entrypoint-instructions\/#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":"Understanding Docker&#8217;s CMD and ENTRYPOINT Instructions"}]},{"@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\/4f5d918df9c19fab91b5b205357ce0b8","name":"Benjamin Cane","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/09c6af2f1a7430456089189937094b817ef1b7c75ab9968bfd3ec35d938d914b?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/09c6af2f1a7430456089189937094b817ef1b7c75ab9968bfd3ec35d938d914b?s=96&d=mm&r=g","caption":"Benjamin Cane"},"description":"Benjamin Cane is a systems architect in the financial services industry. He writes about Linux systems administration on his blog and has recently published his first book, Red Hat Enterprise Linux Troubleshooting Guide.","url":"https:\/\/www.webcodegeeks.com\/author\/benjamin-cane\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17521","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\/158"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=17521"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17521\/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=17521"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17521"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17521"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}