{"id":17129,"date":"2017-05-19T12:15:29","date_gmt":"2017-05-19T09:15:29","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=17129"},"modified":"2017-05-19T11:54:50","modified_gmt":"2017-05-19T08:54:50","slug":"leveraging-dockerignore-file-create-smaller-images","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/","title":{"rendered":"Leveraging the dockerignore File to Create Smaller Images"},"content":{"rendered":"<p>Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a container with a complex <code>Dockerfile<\/code> and a large application turn into a large container image.<\/p>\n<p>A large container image can eventually become troublesome if left unchecked. When deploying a container into production, that production system must download the container from your registry. Ideally this process should be quick, however, network latency (i.e., downloading an image in London from a server in San Franscisco) can cause this process can take a long time.<\/p>\n<p>If you are using services to build your containers, a large container could easily cause those services to timeout. This is also true of deployment automation such as Puppet, SaltStack, or Ansible. Each of these services has a max execution time \u2014 a large image and a slow network connection could make for a messy or failed deployment.<\/p>\n<p>With that said, there are several techniques for keeping images small. In today\u2019s article, we will explore an often-ignored technique, using the <code>.dockerignore<\/code> file.<\/p>\n<h2>Exploring the .dockerignore File<\/h2>\n<p>The <code>.dockerignore<\/code> file is a special file that can be placed within the <strong>build context directory<\/strong>. The build context directory is the directory that we specify at the end of a <code>docker build<\/code> command. The file itself is a simple text file that contains a list of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Glob_(programming)\">glob<\/a> patterns for files and directories to exclude from the final build image.<\/p>\n<p>By leveraging the <code>.dockerignore<\/code> file, we can exclude files and directories we do not need within our final image. To explain this better, let\u2019s walk through a real world example.<\/p>\n<h3>Adding <code>.dockerignore<\/code> to an existing project<\/h3>\n<p>One of the most common locations to store a <code>dockerfile<\/code> is the top level of the application\u2019s code repository. My personal projects are no exception. For this article, we will go ahead and add a <code>.dockerignore<\/code> file to one of my personal open-source projects that leverages Docker.<\/p>\n<p>To get started, let\u2019s first clone the project.<\/p>\n<pre class=\"brush:php\">$ git clone https:\/\/github.com\/madflojo\/automatron.git<\/pre>\n<p>With the project cloned, let\u2019s take a look at the files included in this repository.<\/p>\n<pre class=\"brush:php\">$ cd automatron\/\r\n$ ls -la\r\ntotal 208\r\ndrwxr-xr-x  24 madflojo  users    816 Apr 15 23:00 .\r\ndrwxrwxrwt   7 root      users    238 Apr 15 23:00 ..\r\n-rw-r--r--   1 madflojo  users     29 Apr 15 23:00 .coveragerc\r\ndrwxr-xr-x  13 madflojo  users    442 Apr 15 23:00 .git\r\n-rw-r--r--   1 madflojo  users    834 Apr 15 23:00 .gitignore\r\n-rw-r--r--   1 madflojo  users   5760 Apr 15 23:00 CONTRIBUTING.md\r\n-rw-r--r--   1 madflojo  users    408 Apr 15 23:00 Dockerfile\r\n-rw-r--r--   1 madflojo  users  11343 Apr 15 23:00 LICENSE\r\n-rw-r--r--   1 madflojo  users    220 Apr 15 23:00 Procfile\r\n-rw-r--r--   1 madflojo  users   4538 Apr 15 23:00 README.md\r\n-rw-r--r--   1 madflojo  users   9411 Apr 15 23:00 actioning.py\r\ndrwxr-xr-x   4 madflojo  users    136 Apr 15 23:00 config\r\ndrwxr-xr-x   8 madflojo  users    272 Apr 15 23:00 core\r\n-rw-r--r--   1 madflojo  users   7842 Apr 15 23:00 discovery.py\r\n-rw-r--r--   1 madflojo  users    415 Apr 15 23:00 docker-compose.yml\r\ndrwxr-xr-x  10 madflojo  users    340 Apr 15 23:00 docs\r\n-rw-r--r--   1 madflojo  users   2208 Apr 15 23:00 mkdocs.yml\r\n-rw-r--r--   1 madflojo  users   8609 Apr 15 23:00 monitoring.py\r\ndrwxr-xr-x   9 madflojo  users    306 Apr 15 23:00 plugins\r\n-rw-r--r--   1 madflojo  users    114 Apr 15 23:00 requirements.txt\r\n-rw-r--r--   1 madflojo  users   5992 Apr 15 23:00 runbooks.py\r\ndrwxr-xr-x   5 madflojo  users    170 Apr 15 23:00 tests\r\n-rw-r--r--   1 madflojo  users   1018 Apr 15 23:00 tests.py<\/pre>\n<p>With just a quick look, we can see several files and directories that could be omitted from a production Docker image. Files and directories such as <code>.git\/<\/code>, <code>tests\/<\/code>, <code>mkdocs.yml<\/code>, and even the <code>CONTRIBUTING.md<\/code> file.<\/p>\n<p>Let\u2019s see if these files are included when we perform a <code>docker build<\/code>.<\/p>\n<pre class=\"brush:php\">$ docker build -t automatron .<\/pre>\n<p>The <code>Dockerfile<\/code> within this repository adds files using the following instruction.<\/p>\n<pre class=\"brush:php\">ADD . \/<\/pre>\n<p>This instruction essentially adds all of the files located within the build directory to the <code>\/<\/code> directory within the container. We can see this if we run the container executing the <code>ls -la<\/code> command.<\/p>\n<pre class=\"brush:php\">$ docker run automatron ls -la \/ | grep 2017\r\n-rw-r--r--   1 root root    29 Apr 16  2017 .coveragerc\r\ndrwxr-xr-x   8 root root  4096 Apr 16  2017 .git\r\n-rw-r--r--   1 root root   834 Apr 16  2017 .gitignore\r\n-rw-r--r--   1 root root  5760 Apr 16  2017 CONTRIBUTING.md\r\n-rw-r--r--   1 root root   408 Apr 16  2017 Dockerfile\r\n-rw-r--r--   1 root root 11343 Apr 16  2017 LICENSE\r\n-rw-r--r--   1 root root   220 Apr 16  2017 Procfile\r\n-rw-r--r--   1 root root  4538 Apr 16  2017 README.md\r\n-rw-r--r--   1 root root  9411 Apr 16  2017 actioning.py\r\ndrwxr-xr-x   3 root root  4096 Apr 16  2017 config\r\ndrwxr-xr-x   2 root root  4096 Apr 16  2017 core\r\n-rw-r--r--   1 root root  7842 Apr 16  2017 discovery.py\r\n-rw-r--r--   1 root root   415 Apr 16  2017 docker-compose.yml\r\ndrwxr-xr-x   6 root root  4096 Apr 16  2017 docs\r\n-rw-r--r--   1 root root  2208 Apr 16  2017 mkdocs.yml\r\n-rw-r--r--   1 root root  8609 Apr 16  2017 monitoring.py\r\n-rw-r--r--   1 root root   114 Apr 16  2017 requirements.txt\r\n-rw-r--r--   1 root root  5992 Apr 16  2017 runbooks.py\r\ndrwxr-xr-x   5 root root  4096 Apr 16  2017 tests\r\n-rw-r--r--   1 root root  1018 Apr 16  2017 tests.py<\/pre>\n<p>If we look above, we can see that all of the files from the build directory have been added to the container. Let\u2019s start excluding some of these files, starting with the <code>.git\/<\/code> directory. I am starting with the <code>.git\/<\/code> directory because it\u2019s a commonly large directory that can easily be overlooked.<\/p>\n<p>The <code>.git\/<\/code> directory is a special directory that is used by <code>git<\/code> to store all of the version control meta information. This includes details and even differences of each commit.<\/p>\n<p>This means the more active a project, the larger the <code>.git\/<\/code> directory will be. For my project, the <code>.git\/<\/code> directory is only 1MB in size. However, if we look at the Apache Cassandra project\u2019s <code>.git\/<\/code> directory it is over <strong>200MB<\/strong> in size. This is due to both the size of the codebase and the active nature of the project.<\/p>\n<p>For our example, the <code>.git\/<\/code> directory might not add that much value, but if we were building a container from the Cassandra project\u2019s repository, removing the <code>.git\/<\/code> directory would greatly reduce the size of the resulting container image.<\/p>\n<p>With that said, let\u2019s go ahead and add the <code>.git\/<\/code> directory to a newly created <code>.dockerignore<\/code> file. We can do this by adding the following:<\/p>\n<p><code>.git<\/code><\/p>\n<p>Once this line is added, let\u2019s build the container again and check the resulting contents.<\/p>\n<pre class=\"brush:php\">$ docker build -t automatron .\r\n$ docker run automatron ls -la \/ | grep 2017\r\n-rw-r--r--   1 root root    29 Apr 16  2017 .coveragerc\r\n-rw-r--r--   1 root root     5 Apr 16  2017 .dockerignore\r\n-rw-r--r--   1 root root   834 Apr 16  2017 .gitignore\r\n-rw-r--r--   1 root root  5760 Apr 16  2017 CONTRIBUTING.md\r\n-rw-r--r--   1 root root   408 Apr 16  2017 Dockerfile\r\n-rw-r--r--   1 root root 11343 Apr 16  2017 LICENSE\r\n-rw-r--r--   1 root root   220 Apr 16  2017 Procfile\r\n-rw-r--r--   1 root root  4538 Apr 16  2017 README.md\r\n-rw-r--r--   1 root root  9411 Apr 16  2017 actioning.py\r\ndrwxr-xr-x   3 root root  4096 Apr 16  2017 config\r\ndrwxr-xr-x   2 root root  4096 Apr 16  2017 core\r\n-rw-r--r--   1 root root  7842 Apr 16  2017 discovery.py\r\n-rw-r--r--   1 root root   415 Apr 16  2017 docker-compose.yml\r\ndrwxr-xr-x   6 root root  4096 Apr 16  2017 docs\r\n-rw-r--r--   1 root root  2208 Apr 16  2017 mkdocs.yml\r\n-rw-r--r--   1 root root  8609 Apr 16  2017 monitoring.py\r\n-rw-r--r--   1 root root   114 Apr 16  2017 requirements.txt\r\n-rw-r--r--   1 root root  5992 Apr 16  2017 runbooks.py\r\ndrwxr-xr-x   5 root root  4096 Apr 16  2017 tests\r\n-rw-r--r--   1 root root  1018 Apr 16  2017 tests.py<\/pre>\n<p>As we can see from the resulting output, the container is now missing the <code>.git\/<\/code> directory.<\/p>\n<p>The above is a simple example of using the <code>.dockerignore<\/code> file. At this point, we could simply add a similar entry for each file and directory we wish to omit and we could have a smaller resulting image. There is, however, an easier way.<\/p>\n<p>As I mentioned earlier, the <code>.dockerignore<\/code> file understands Unix glob patterns. If, for example, we wanted to omit all files that started with a <code>.<\/code>, we could simply add <code>.*<\/code> to the file.<\/p>\n<p>It is important to note that <a href=\"https:\/\/en.wikipedia.org\/wiki\/Glob_(programming)\">Unix style glob patterns<\/a> are not regular expressions. <code>.*<\/code> is a prime example of this. In a \u201cglob\u201d pattern, this matches everything that starts with a <code>.<\/code>. In a regular expression, this would match every character, essentially matching every file and directory.<\/p>\n<p>Since the <code>.dockerignore<\/code> file uses Unix style glob patterns, we can safely add <code>.*<\/code> and only dot-files will be excluded.<\/p>\n<p>In addition to <code>.*<\/code>, let\u2019s go ahead and add a few more items to omit.<\/p>\n<pre class=\"brush:php\">.*\r\ndocs\r\nmkdocs.yml\r\ndocker-compose.yml\r\ntest*\r\n*.md<\/pre>\n<p>In the above, we have some clearly specified items such as <code>docs\/<\/code>, <code>docker-compose.yml<\/code>, and <code>mkdocs.yml<\/code>. We also have some glob patterns such as <code>test*<\/code>, which will cause us to omit <code>tests\/<\/code> and <code>tests.py<\/code>. We also have another interesting one: <code>*.md<\/code>, which will cause Docker to omit any markdown file such as <code>README.md<\/code> and <code>CONTRIBUTING.md<\/code>.<\/p>\n<p>Let\u2019s see how this comes together by running another build and <code>ls -la<\/code>.<\/p>\n<pre class=\"brush:php\">$ docker build -t automatron .\r\n$ docker run automatron ls -la \/ | grep 2017\r\n-rw-r--r--   1 root root   408 Apr 16  2017 Dockerfile\r\n-rw-r--r--   1 root root 11343 Apr 16  2017 LICENSE\r\n-rw-r--r--   1 root root   220 Apr 16  2017 Procfile\r\n-rw-r--r--   1 root root  9411 Apr 16  2017 actioning.py\r\ndrwxr-xr-x   3 root root  4096 Apr 16  2017 config\r\ndrwxr-xr-x   2 root root  4096 Apr 16  2017 core\r\n-rw-r--r--   1 root root  7842 Apr 16  2017 discovery.py\r\n-rw-r--r--   1 root root  8609 Apr 16  2017 monitoring.py\r\n-rw-r--r--   1 root root   114 Apr 16  2017 requirements.txt\r\n-rw-r--r--   1 root root  5992 Apr 16  2017 runbooks.py<\/pre>\n<p>The output this time is quite a bit less than our previous run. We can see that we are now missing the files we wanted to omit.<\/p>\n<p>At this point, we have achieved our goal: we eliminated files that were not needed within our final image. There is, however, one file missing that I wanted to include.<\/p>\n<p>!Sign up for a free Codeship Account<\/p>\n<h3>Using ! to include files<\/h3>\n<p>The missing file is the <code>README.md<\/code> file. In the <code>.dockerignore<\/code> file, we added a line <code>*.md<\/code> to omit all markdown files. My project has a few markdown files already and I fully expect more to pop up in the future.<\/p>\n<p>The problem is I\u2019d like to include only the <code>README.md<\/code> and no other markdown files. I\u2019d also like to not have to specify each and every markdown file to accomplish this. Luckily, Docker provides this ability.<\/p>\n<p>By adding the following, we can keep our removal of all markdown files but still retain our <code>README.md<\/code>:<\/p>\n<pre class=\"brush:php\">.*\r\ndocs\r\nmkdocs.yml\r\ndocker-compose.yml\r\ntest*\r\n*.md\r\n!README.md<\/pre>\n<p>With the above, we simply added the <code>README.md<\/code> file with the <code>!<\/code> character in front of it. This tells Docker to include the <code>README.md<\/code> or rather exclude it from other exclusions.<\/p>\n<p>Let\u2019s go ahead and see what files our container includes with our changes applied.<\/p>\n<pre class=\"brush:php\">$ docker build -t automatron .\r\n$ docker run automatron ls -la \/ | grep 2017\r\n-rw-r--r--   1 root root   408 Apr 16  2017 Dockerfile\r\n-rw-r--r--   1 root root 11343 Apr 16  2017 LICENSE\r\n-rw-r--r--   1 root root   220 Apr 16  2017 Procfile\r\n-rw-r--r--   1 root root  4538 Apr 16  2017 README.md\r\n-rw-r--r--   1 root root  9411 Apr 16  2017 actioning.py\r\ndrwxr-xr-x   3 root root  4096 Apr 16  2017 config\r\ndrwxr-xr-x   2 root root  4096 Apr 16  2017 core\r\n-rw-r--r--   1 root root  7842 Apr 16  2017 discovery.py\r\n-rw-r--r--   1 root root  8609 Apr 16  2017 monitoring.py\r\n-rw-r--r--   1 root root   114 Apr 16  2017 requirements.txt\r\n-rw-r--r--   1 root root  5992 Apr 16  2017 runbooks.py<\/pre>\n<p>With the <code>!README.md<\/code> entry added, we can now see our <code>README.md<\/code> was included but not our <code>CONTRIBUTING.md<\/code>. This means our instruction to omit all markdown files (<code>*.md<\/code>) was applied to all except the <code>README.md<\/code>.<\/p>\n<h2>Summary<\/h2>\n<p>In this article, we covered how to leverage the <code>.dockerignore<\/code> file to exclude unnecessary files and directories from the container build. As we found out, the usage of the <code>.dockerignore<\/code> file is very simple. Do you have any <code>.dockerignore<\/code> tips or tricks? Add it to the comments or tweet it to us.<\/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\/leveraging-the-dockerignore-file-to-create-smaller-images\/\">Leveraging the dockerignore File to Create Smaller Images<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a>\u00a0Ben 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>Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a container with a complex Dockerfile and a large application turn into a large container image. A large container image can eventually become troublesome if left unchecked. When &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-17129","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>Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a\" \/>\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\/leveraging-dockerignore-file-create-smaller-images\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\" \/>\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-05-19T09:15:29+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=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\"},\"author\":{\"name\":\"Benjamin Cane\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4f5d918df9c19fab91b5b205357ce0b8\"},\"headline\":\"Leveraging the dockerignore File to Create Smaller Images\",\"datePublished\":\"2017-05-19T09:15:29+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\"},\"wordCount\":1179,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#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\/leveraging-dockerignore-file-create-smaller-images\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\",\"name\":\"Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg\",\"datePublished\":\"2017-05-19T09:15:29+00:00\",\"description\":\"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#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\/leveraging-dockerignore-file-create-smaller-images\/#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\":\"Leveraging the dockerignore File to Create Smaller Images\"}]},{\"@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":"Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026","description":"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a","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\/leveraging-dockerignore-file-create-smaller-images\/","og_locale":"en_US","og_type":"article","og_title":"Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026","og_description":"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a","og_url":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-05-19T09:15:29+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":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/"},"author":{"name":"Benjamin Cane","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/4f5d918df9c19fab91b5b205357ce0b8"},"headline":"Leveraging the dockerignore File to Create Smaller Images","datePublished":"2017-05-19T09:15:29+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/"},"wordCount":1179,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#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\/leveraging-dockerignore-file-create-smaller-images\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/","url":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/","name":"Leveraging the dockerignore File to Create Smaller Images - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2016\/01\/docker-logo.jpg","datePublished":"2017-05-19T09:15:29+00:00","description":"Keeping container image sizes small is one of the most common \u201cbest practice\u201d tips out there. There is good reason for this; it\u2019s very simple to let a","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/devops\/leveraging-dockerignore-file-create-smaller-images\/#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\/leveraging-dockerignore-file-create-smaller-images\/#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":"Leveraging the dockerignore File to Create Smaller Images"}]},{"@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\/17129","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=17129"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/17129\/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=17129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=17129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=17129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}