{"id":1243,"date":"2024-07-23T12:16:04","date_gmt":"2024-07-23T12:16:04","guid":{"rendered":"https:\/\/dockerpros.com\/?post_type=glossary&#038;p=1243"},"modified":"2024-07-23T12:21:33","modified_gmt":"2024-07-23T12:21:33","slug":"docker-build-context","status":"publish","type":"glossary","link":"https:\/\/dockerpros.com\/it\/wiki\/docker-build-context\/","title":{"rendered":"Docker Build Context"},"content":{"rendered":"<h1>Understanding Docker Build Context: An In-Depth Exploration<\/h1>\n<p>Docker Build Context refers to the files and directories that are sent to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> when a Docker <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is built using the <code>docker build<\/code> command. This context essentially acts as a working directory that contains the necessary files for the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> creation process, including the <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> itself, application code, configuration files, and any other resources required to successfully build the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Understanding how build context works is critical for optimizing Docker workflows, managing resources, and ensuring efficient and effective <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> builds.<\/p>\n<h2>Table of Contents<\/h2>\n<ol>\n<li><a href=\"#the-importance-of-build-context\">The Importance of Build Context<\/a><\/li>\n<li><a href=\"#how-build-context-works\">How Build Context Works<\/a><\/li>\n<li><a href=\"#best-practices-for-managing-build-context\">Best Practices for Managing Build Context<\/a><\/li>\n<li><a href=\"#size-matters-understanding-build-context-size\">Size Matters: Understanding Build Context Size<\/a><\/li>\n<li><a href=\"#excluding-files-from-build-context\">Excluding Files from Build Context<\/a><\/li>\n<li><a href=\"#using-dockerignore\">Using .dockerignore<\/a><\/li>\n<li><a href=\"#multistage-builds-and-build-context\">Multistage Builds and Build Context<\/a><\/li>\n<li><a href=\"#common-build-context-pitfalls\">Common Build Context Pitfalls<\/a><\/li>\n<li><a href=\"#conclusion\">Conclusion<\/a><\/li>\n<\/ol>\n<h2>The Importance of Build Context<\/h2>\n<p>The build context plays a pivotal role in how Docker constructs images. It not only defines what files are available during the build process but also influences performance and efficiency. A well-structured build context can reduce the time required to build images, lower <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/network\/\" target=\"_blank\">network<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> overhead, and improve overall resource management.<\/p>\n<p>For developers and DevOps engineers, managing the build context effectively translates to faster iterations, reduced build times, and a more streamlined deployment pipeline. Given that Docker is extensively used in Continuous Integration\/Continuous Deployment (CI\/CD) environments, an optimized build context can have a significant impact on development cycles and operational efficiency.<\/p>\n<h2>How Build Context Works<\/h2>\n<p>When you execute the <code>docker build<\/code> command, Docker sends the specified build context to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. The command typically looks like this:<\/p>\n<pre><code class=\"language-bash\">docker build -t my-image:latest .<\/code><\/pre>\n<p>In this example, the <code>.<\/code> denotes the current directory as the build context. Docker first creates a tarball of this directory and any files it contains, sending it to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, which is responsible for executing the build process.<\/p>\n<p>Once the <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> receives the context, it inspects the <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and uses the available files and directories to build the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. The <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> defines the steps required to create the image\u2014from selecting a base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to adding and configuring application files.<\/p>\n<h3>The Layers of Docker Images<\/h3>\n<p>Each command in a <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> corresponds to a layer in the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. The build context is essential for accessing the necessary files for these commands. For instance, when you have a command that copies application code into the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:<\/p>\n<pre><code class=\"language-dockerfile\"><span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\" target=\"_blank\">COPY<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">COPY is a command in computer programming and data management that facilitates the duplication of files or data from one location to another, ensuring data integrity and accessibility.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> .\/app \/app<\/code><\/pre>\n<p>The <code><span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\" target=\"_blank\">COPY<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">COPY is a command in computer programming and data management that facilitates the duplication of files or data from one location to another, ensuring data integrity and accessibility.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> command relies on the build context to locate <code>.\/app<\/code>. If the required files are not present within the context, the build will fail.<\/p>\n<h2>Best Practices for Managing Build Context<\/h2>\n<p>Effectively managing your build context can lead to significant performance gains during the <span class=\"glossaryai-tooltip glossary-term-1230\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-image-build\/\" target=\"_blank\">Docker image build<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker image build is a process that creates a Docker image from a set of instructions defined in a Dockerfile. It encapsulates an application and its dependencies, ensuring consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-image-build\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> process. Here are some best practices to consider:<\/p>\n<h3>Keep Context Size Minimal<\/h3>\n<p>Only include files necessary for the build in your context. Large contexts can lead to longer transfer times, increased memory usage, and slower builds. <\/p>\n<h3>Organize Your Directories<\/h3>\n<p>Structuring your project directory logically can help maintain a manageable build context. For example, you might have separate folders for application code, configuration files, and dependencies.<\/p>\n<h3>Utilize Relative Paths<\/h3>\n<p>When referencing files in your <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, use relative paths to reduce ambiguity. This makes it clearer which files are being used and promotes better organization.<\/p>\n<h3>Use Multistage Builds<\/h3>\n<p>Multistage builds allow you to separate the build environment from the runtime environment, reducing the size of the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and optimizing the build context. In these scenarios, you can <span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\" target=\"_blank\">copy<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">COPY is a command in computer programming and data management that facilitates the duplication of files or data from one location to another, ensuring data integrity and accessibility.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> only the necessary artifacts to the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<h2>Size Matters: Understanding Build Context Size<\/h2>\n<p>The size of your build context can greatly impact the efficiency of your Docker builds. A larger context means more data that needs to be transferred to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, which can slow down the build process. Here are some considerations regarding build context size:<\/p>\n<h3>Impact on Build Time<\/h3>\n<p>When you <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> <code>docker build<\/code>, Docker packages the entire context and sends it to the <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. If your context is large, this operation can take considerable time, especially if you are working in a CI\/CD environment where frequent builds are the norm.<\/p>\n<h3>Network Constraints<\/h3>\n<p>In distributed systems, where the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> might reside on a different machine than the client executing the build command, the <span class=\"glossaryai-tooltip glossary-term-661\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/network\/\" target=\"_blank\">network<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A network, in computing, refers to a collection of interconnected devices that communicate and share resources. It enables data exchange, facilitates collaboration, and enhances operational efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/network\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> bandwidth can become a bottleneck. A large build context increases the amount of data transferred and can slow down the entire workflow.<\/p>\n<h3>Disk Space Usage<\/h3>\n<p>A large build context can also lead to increased disk space usage on the Docker host. This can become problematic, especially when multiple builds are <span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/run\/\" target=\"_blank\">run<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">\"RUN\" refers to a command in various programming languages and operating systems to execute a specified program or script. It initiates processes, providing a controlled environment for task execution.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in parallel, leading to unnecessary consumption of disk resources.<\/p>\n<h2>Excluding Files from Build Context<\/h2>\n<p>Efficiently managing your build context often involves excluding unnecessary files. To do this, you can utilize the <code>.dockerignore<\/code> file.<\/p>\n<h3>What is <code>.dockerignore<\/code>?<\/h3>\n<p>The <code>.dockerignore<\/code> file functions similarly to the <code>.gitignore<\/code> file used in Git. It specifies files and directories that should be excluded from the build context, preventing them from being sent to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<p>This can significantly reduce the size of your build context, improving build times and reducing resource consumption. The syntax for the <code>.dockerignore<\/code> file is straightforward; each line represents a file or directory to ignore. Here\u2019s a simple example:<\/p>\n<pre><code># Ignore all log files\n*.log\n\n# Ignore node_modules directory\nnode_modules\n\n# Ignore .git directory\n.git<\/code><\/pre>\n<h3>Advantages of Using <code>.dockerignore<\/code><\/h3>\n<ol>\n<li>\n<p><strong>Reduced Build Context Size<\/strong>: By excluding unneeded files, you reduce the amount of data sent to the Docker <span class=\"glossaryai-tooltip glossary-term-667\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\" target=\"_blank\">daemon<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A daemon is a background process in computing that runs autonomously, performing tasks without user intervention. It typically handles system or application-level functions, enhancing efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/daemon\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, leading to faster builds.<\/p>\n<\/li>\n<li>\n<p><strong>Enhanced Security<\/strong>: Sensitive files or files with credentials can be excluded from the build context, reducing the risk of accidental exposure in the built <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<\/li>\n<li>\n<p><strong>Cleaner Images<\/strong>: Excluding temporary files or unnecessary folders helps create cleaner, more manageable images.<\/p>\n<\/li>\n<\/ol>\n<h2>Using <code>.dockerignore<\/code><\/h2>\n<p>To create a <code>.dockerignore<\/code> file, simply <span class=\"glossaryai-tooltip glossary-term-674\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/add\/\" target=\"_blank\">add<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">The ADD instruction in Docker is a command used in Dockerfiles to copy files and directories from a host machine into a Docker image during the build process. It not only facilitates the transfer of local files but also provides additional functionality, such as automatically extracting compressed files and fetching remote files via HTTP or HTTPS.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/add\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> it to the root of your build context directory. Place any patterns you want to exclude from the build process within this file. <\/p>\n<h3>Example of a <code>.dockerignore<\/code> File<\/h3>\n<p>Here\u2019s an example:<\/p>\n<pre><code># Ignore node_modules directory\nnode_modules\n\n# Ignore log files\n*.log\n\n# Ignore all .env files\n.env\n\n# Ignore any test files\ntests\/<\/code><\/pre>\n<p>Each of these patterns helps streamline the build context, ensuring that only essential files are included during the build process.<\/p>\n<h2>Multistage Builds and Build Context<\/h2>\n<p>Multistage builds allow you to break down the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> creation process into multiple stages, each with its own build context. This strategy can significantly enhance efficiency by allowing larger, resource-intensive builds to occur in isolated stages before copying only what is needed to the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<h3>How Multistage Builds Work<\/h3>\n<p>In a multistage build, you can define multiple <code>FROM<\/code> statements in a single <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. Each <code>FROM<\/code> statement starts a new build stage, and you can reference files from one stage to another:<\/p>\n<pre><code class=\"language-dockerfile\"># First stage: Builder\nFROM golang:1.16 AS builder\nWORKDIR \/app\nCOPY . .\nRUN go build -o myapp\n\n# Second stage: Final image\nFROM alpine:latest\nCOPY --from=builder \/app\/myapp \/usr\/local\/bin\/myapp\nENTRYPOINT [\"myapp\"]<\/code><\/pre>\n<p>In this example, the first stage builds a Go application, while the second stage creates a minimal Alpine <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> that only contains the built application. <\/p>\n<h3>Benefits of Multistage Builds<\/h3>\n<ol>\n<li>\n<p><strong>Smaller Final Images<\/strong>: Only the necessary artifacts are included in the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, leading to smaller and more secure images.<\/p>\n<\/li>\n<li>\n<p><strong>Reduced Complexity<\/strong>: Each stage can be handled independently, simplifying the build process.<\/p>\n<\/li>\n<li>\n<p><strong>Optimized Build Context<\/strong>: Since each stage can have its own context, it allows for more tailored management of what files are included.<\/p>\n<\/li>\n<\/ol>\n<h2>Common Build Context Pitfalls<\/h2>\n<ol>\n<li>\n<p><strong>Accidental Inclusion of Large Files<\/strong>: Developers often forget to exclude large assets (like media files) from their build contexts, leading to longer build times. Always review your <code>.dockerignore<\/code> file carefully.<\/p>\n<\/li>\n<li>\n<p><strong>Confusing File Paths<\/strong>: Using absolute paths in the <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\" target=\"_blank\">Dockerfile<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A Dockerfile is a script containing a series of instructions to automate the creation of Docker images. It specifies the base image, application dependencies, and configuration, facilitating consistent deployment across environments.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can lead to confusion and errors. Stick with relative paths for clarity.<\/p>\n<\/li>\n<li>\n<p><strong>Inconsistent Build Environments<\/strong>: Failing to use multistage builds appropriately can lead to bloated images that include unnecessary dependencies or files. Ensure that each <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> stage is purposeful and efficient.<\/p>\n<\/li>\n<li>\n<p><strong>Neglecting Security<\/strong>: Sensitive configuration files sometimes end up in the build context. Always review your <code>.dockerignore<\/code> to prevent this.<\/p>\n<\/li>\n<li>\n<p><strong>Poor Organization<\/strong>: A disorganized project directory can lead to confusion about which files should be included in the build context. Maintain a clean and logical directory structure.<\/p>\n<\/li>\n<\/ol>\n<h2>Conclusion<\/h2>\n<p>Understanding Docker build context is essential for developers and DevOps engineers aiming to optimize the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">image<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> building process. From managing the size and structure of your build context to leveraging tools like <code>.dockerignore<\/code> and features like multistage builds, there are numerous strategies to ensure efficient and effective Docker workflows.<\/p>\n<p>As Docker continues to evolve, staying updated with best practices for managing build context will help you leverage the full power of containerization in your development and deployment processes, resulting in improved performance, enhanced security, and an overall smoother development experience. By adhering to the principles outlined in this article, you can significantly enhance your Docker workflows and contribute to a more efficient software development lifecycle.<\/p>","protected":false},"excerpt":{"rendered":"<p>Il contesto di build Docker si riferisce ai file e directory disponibili durante il... <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\" target=\"_blank\">immagine<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">An image is a visual representation of an object or scene, typically composed of pixels in digital formats. It can convey information, evoke emotions, and facilitate communication across various media.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/it\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> processo di compilazione. \u00c8 fondamentale per accedere al codice dell'applicazione e alle dipendenze, influenzando l'efficienza e la sicurezza.<\/p>","protected":false},"author":1,"featured_media":1803,"parent":0,"template":"","glossary-cat":[],"class_list":["post-1243","glossary","type-glossary","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Docker Build Context - Dockerpros<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/dockerpros.com\/it\/wiki\/docker-build-context\/\" \/>\n<meta property=\"og:locale\" content=\"it_IT\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Docker Build Context - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"Docker build context refers to the files and directories available during the image build process. It is crucial for accessing application code and dependencies, influencing efficiency and security.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/it\/wiki\/docker-build-context\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-23T12:21:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Tempo di lettura stimato\" \/>\n\t<meta name=\"twitter:data1\" content=\"7 minuti\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/\",\"url\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/\",\"name\":\"Docker Build Context - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg\",\"datePublished\":\"2024-07-23T12:16:04+00:00\",\"dateModified\":\"2024-07-23T12:21:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#breadcrumb\"},\"inLanguage\":\"it-IT\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg\",\"width\":800,\"height\":600,\"caption\":\"docker-build-context-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/dockerpros.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Glossary\",\"item\":\"https:\/\/dockerpros.com\/fr\/wiki\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Docker Build Context\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/dockerpros.com\/#website\",\"url\":\"https:\/\/dockerpros.com\/\",\"name\":\"Dockerpros\",\"description\":\"DockerPros \u2013 Your Ultimate Docker Resource Hub\",\"publisher\":{\"@id\":\"https:\/\/dockerpros.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/dockerpros.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"it-IT\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"it-IT\",\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png\",\"width\":532,\"height\":114,\"caption\":\"Dockerpros\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Docker Build Context - Dockerpros","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:\/\/dockerpros.com\/it\/wiki\/docker-build-context\/","og_locale":"it_IT","og_type":"article","og_title":"Docker Build Context - Dockerpros","og_description":"Docker build context refers to the files and directories available during the image build process. It is crucial for accessing application code and dependencies, influencing efficiency and security.","og_url":"https:\/\/dockerpros.com\/it\/wiki\/docker-build-context\/","og_site_name":"Dockerpros","article_modified_time":"2024-07-23T12:21:33+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Tempo di lettura stimato":"7 minuti"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/","url":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/","name":"Docker Build Context - Dockerpros","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg","datePublished":"2024-07-23T12:16:04+00:00","dateModified":"2024-07-23T12:21:33+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#breadcrumb"},"inLanguage":"it-IT","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/"]}]},{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/docker-build-context_1243.jpg","width":800,"height":600,"caption":"docker-build-context-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/es\/wiki\/contexto-de-compilacion-de-dockerel-contexto-de-compilacion-de-docker-es-el-conjunto-de-archivos-y-directorios-que-se-envian-al-demonio-de-docker-cuando-se-ejecuta-el-comando-docker-build-este-cont\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/dockerpros.com\/"},{"@type":"ListItem","position":2,"name":"Glossary","item":"https:\/\/dockerpros.com\/fr\/wiki\/"},{"@type":"ListItem","position":3,"name":"Docker Build Context"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Esperti Docker","description":"DockerPros \u2013 Il tuo punto di riferimento definitivo per Docker","publisher":{"@id":"https:\/\/dockerpros.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/dockerpros.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"it-IT"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Esperti Docker","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"it-IT","@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/Dockerpros_logo_blanco.png","width":532,"height":114,"caption":"Dockerpros"},"image":{"@id":"https:\/\/dockerpros.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary\/1243","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary\/1243\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/media\/1803"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/media?parent=1243"}],"wp:term":[{"taxonomy":"glossary-cat","embeddable":true,"href":"https:\/\/dockerpros.com\/it\/wp-json\/wp\/v2\/glossary-cat?post=1243"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}