{"id":1307,"date":"2024-07-23T12:20:09","date_gmt":"2024-07-23T12:20:09","guid":{"rendered":"https:\/\/dockerpros.com\/?post_type=glossary&#038;p=1307"},"modified":"2024-07-23T12:22:58","modified_gmt":"2024-07-23T12:22:58","slug":"dockerfile-from","status":"publish","type":"glossary","link":"https:\/\/dockerpros.com\/es\/wiki\/dockerfile-from\/","title":{"rendered":"Dockerfile DESDE"},"content":{"rendered":"<h1>Understanding the Dockerfile FROM Instruction<\/h1>\n<p>In the realm of containerization, Docker has emerged as a pivotal technology that enables developers to package applications and their dependencies into containers. At the heart of this process lies the <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, a script containing a series of instructions on how to build a Docker <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. One of the fundamental instructions in a <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is <code>FROM<\/code>, which specifies the base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> upon which the Docker <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will be built. Understanding the nuances of the <code>FROM<\/code> instruction is crucial for creating efficient, maintainable, and portable Docker images.<\/p>\n<h2>The Role of <code>FROM<\/code> in Dockerfile<\/h2>\n<p>The <code>FROM<\/code> instruction sets the foundation for a Docker <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. It defines the starting point for the build process by referencing an existing <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> from the <span class=\"glossaryai-tooltip glossary-term-653\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/docker-hub\/\" target=\"_blank\">Docker Hub<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Hub is a cloud-based repository for storing and sharing container images. It facilitates version control, collaborative development, and seamless integration with Docker CLI for efficient container management.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/docker-hub\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> or a custom <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> stored in a <span class=\"glossaryai-tooltip glossary-term-737\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/private-registry\/\" target=\"_blank\">private registry<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">A private registry is a secure repository for managing and storing container images, allowing organizations to control access, enhance security, and streamline deployment processes within their infrastructure.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/private-registry\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. By using <code>FROM<\/code>, developers can leverage pre-built images that contain essential operating system components, programming languages, or frameworks, thereby reducing the complexity of their own Docker images.<\/p>\n<h3>Syntax of the <code>FROM<\/code> Instruction<\/h3>\n<p>The basic syntax of the <code>FROM<\/code> instruction is straightforward:<\/p>\n<pre><code class=\"language-dockerfile\">FROM [:]<\/code><\/pre>\n<ul>\n<li>&#8220;: The name of the base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> you want to use.<\/li>\n<li><code>`: An optional field that specifies the version of the <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. If omitted, Docker defaults to the<\/code>latest` tag.<\/li>\n<\/ul>\n<p>Example:<\/p>\n<pre><code class=\"language-dockerfile\">FROM ubuntu:20.04<\/code><\/pre>\n<p>In this case, the Docker <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> will be based on Ubuntu version 20.04.<\/p>\n<h2>Types of Base Images<\/h2>\n<h3>Official Images<\/h3>\n<p><span class=\"glossaryai-tooltip glossary-term-653\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/docker-hub\/\" target=\"_blank\">Docker Hub<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Docker Hub is a cloud-based repository for storing and sharing container images. It facilitates version control, collaborative development, and seamless integration with Docker CLI for efficient container management.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/docker-hub\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> hosts a plethora of official images that are maintained by the Docker community or supported by software vendors. These images are typically well-documented, regularly updated, and adhere to best practices, making them a reliable choice for many applications. Examples include:<\/p>\n<ul>\n<li><code>ubuntu<\/code>: A lightweight version of the Ubuntu operating system.<\/li>\n<li><code><span class=\"glossaryai-tooltip glossary-term-684\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\" target=\"_blank\">node<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Node, or Node.js, is a JavaScript runtime built on Chrome's V8 engine, enabling server-side scripting. It allows developers to build scalable network applications using asynchronous, event-driven architecture.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code>: A base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> for <span class=\"glossaryai-tooltip glossary-term-684\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\" target=\"_blank\">Node<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Node, or Node.js, is a JavaScript runtime built on Chrome's V8 engine, enabling server-side scripting. It allows developers to build scalable network applications using asynchronous, event-driven architecture.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.js applications.<\/li>\n<li><code>python<\/code>: A base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> for Python applications.<\/li>\n<\/ul>\n<h3>Custom Images<\/h3>\n<p>In some cases, developers may need to create custom images that serve as base images for their projects. This is particularly useful when specific dependencies or configurations are required that are not available in the official images. Creating a custom base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can be accomplished by using the <code>FROM<\/code> instruction to build upon a simpler <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and adding the necessary components.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-dockerfile\">FROM alpine:3.12\n<span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> apk <span class=\"glossaryai-tooltip glossary-term-674\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/add\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> --no-cache openjdk11<\/code><\/pre>\n<p>This example starts with the minimal Alpine Linux <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> and installs OpenJDK 11, resulting in a custom <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> tailored for Java applications.<\/p>\n<h3>Multi-Stage Builds<\/h3>\n<p>One of the more advanced features of Docker is the ability to use multi-stage builds, which allow developers to create more efficient images by separating the build environment from the production environment. Each <code>FROM<\/code> instruction defines a new stage in the build process, enabling developers to <span class=\"glossaryai-tooltip glossary-term-673\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/copy\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> only the necessary artifacts from one stage to the next.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-dockerfile\"># Build stage\nFROM golang:1.16 AS builder\nWORKDIR \/app\nCOPY . .\nRUN go build -o myapp\n\n# Production stage\nFROM alpine:3.12\nWORKDIR \/app\nCOPY --from=builder \/app\/myapp .\nCMD [\".\/myapp\"]<\/code><\/pre>\n<p>In this example, the first stage uses the Go <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> to compile the application, while the second stage creates a minimal <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> that only includes the executable, significantly reducing the final <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> size.<\/p>\n<h2>Best Practices for Using <code>FROM<\/code><\/h2>\n<h3>Choosing the Right Base Image<\/h3>\n<p>Selecting an appropriate base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> is crucial for the performance, security, and maintainability of Docker images. Here are some guidelines:<\/p>\n<ol>\n<li>\n<p><strong>Minimize <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> Size<\/strong>: Use smaller images (e.g., Alpine or BusyBox) when possible to reduce the overall size of your Docker images.<\/p>\n<\/li>\n<li>\n<p><strong>Use Official Images<\/strong>: Whenever feasible, leverage official images as they are usually well-maintained, tested, and optimized for performance.<\/p>\n<\/li>\n<li>\n<p><strong>Stay Updated<\/strong>: Regularly check for updates to base images and their dependencies to ensure security and compatibility.<\/p>\n<\/li>\n<li>\n<p><strong>Avoid Unnecessary Layers<\/strong>: Combine multiple commands into a single <code><span class=\"glossaryai-tooltip glossary-term-672\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/run\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span><\/code> instruction when appropriate to minimize the number of <span class=\"glossaryai-tooltip glossary-term-739\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/image-layers\/\" target=\"_blank\">image layers<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Image layers are fundamental components in graphic design and editing software, allowing for the non-destructive manipulation of elements. Each layer can contain different images, effects, or adjustments, enabling precise control over composition and visual effects.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/image-layers\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>, improving build performance and efficiency.<\/p>\n<\/li>\n<\/ol>\n<h3>Version Control<\/h3>\n<p>When specifying an <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> in the <code>FROM<\/code> instruction, consider using a specific tag rather than <code>latest<\/code>. Relying on <code>latest<\/code> can lead to unpredictable builds, as the base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> may change unexpectedly. Using specific version tags ensures that your builds are reproducible and maintain a consistent runtime environment.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-dockerfile\">FROM <span class=\"glossaryai-tooltip glossary-term-684\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\" target=\"_blank\">node<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Node, or Node.js, is a JavaScript runtime built on Chrome's V8 engine, enabling server-side scripting. It allows developers to build scalable network applications using asynchronous, event-driven architecture.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:14.17.0<\/code><\/pre>\n<h3>Using Build Arguments<\/h3>\n<p>Sometimes, you may need to customize the base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> based on build-time variables. You can achieve this by using build arguments in conjunction with the <code>FROM<\/code> instruction.<\/p>\n<p>Example:<\/p>\n<pre><code class=\"language-dockerfile\"><span class=\"glossaryai-tooltip glossary-term-679\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/arg\/\" target=\"_blank\">ARG<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">ARG is a directive used within Dockerfiles to define build-time variables that allow you to parameterize your builds. These variables can influence how an image is constructed, enabling developers to create more flexible and reusable Docker images.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/arg\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> BASE_IMAGE=<span class=\"glossaryai-tooltip glossary-term-684\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\" target=\"_blank\">node<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Node, or Node.js, is a JavaScript runtime built on Chrome's V8 engine, enabling server-side scripting. It allows developers to build scalable network applications using asynchronous, event-driven architecture.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/node\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>:14\nFROM ${BASE_IMAGE}<\/code><\/pre>\n<p>In this case, you can specify the <code>BASE_IMAGE<\/code> argument during the build process to easily switch between different base images.<\/p>\n<h2>Common Pitfalls with <code>FROM<\/code><\/h2>\n<p>While the <code>FROM<\/code> instruction is straightforward, it can lead to issues if not used judiciously. Here are some common pitfalls to avoid:<\/p>\n<h3>Ignoring Security Best Practices<\/h3>\n<p>Using outdated or unmaintained base images can introduce vulnerabilities into your application. Always review and update base images regularly, and consider scanning images for security vulnerabilities before deployment.<\/p>\n<h3>Overly Complex Base Images<\/h3>\n<p>Using overly complex base images can lead to bloated images that take longer to build and deploy. Aim to create minimal images that contain only the essential components required for your application.<\/p>\n<h3>Neglecting Cache Management<\/h3>\n<p>Docker uses a layer caching mechanism to optimize builds. However, if you frequently change the <code>FROM<\/code> instruction or the images being used, you may inadvertently bypass cached layers, leading to longer build times. Be mindful of caching behavior when designing your <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>.<\/p>\n<h2>Conclusion<\/h2>\n<p>The <code>FROM<\/code> instruction is a foundational element of Dockerfiles that plays a critical role in defining the base upon which Docker images are built. By understanding its syntax, types of base images, and best practices, developers can create efficient, reliable, and secure Docker images that enhance the portability and scalability of their applications. As you gain proficiency with Docker and its capabilities, remember that the choice of base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> can significantly impact your development workflow, deployment strategies, and the overall performance of your applications. Embrace the power of the <code>FROM<\/code> instruction, and leverage it wisely to unlock the full potential of containerization in your projects.<\/p>","protected":false},"excerpt":{"rendered":"<p>La instrucci\u00f3n \u201cFROM\u201d en un <span class=\"glossaryai-tooltip glossary-term-652\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/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\">Un Dockerfile es un script que contiene una serie de instrucciones para automatizar la creaci\u00f3n de im\u00e1genes Docker. Especifica la imagen base, las dependencias de la aplicaci\u00f3n y la configuraci\u00f3n, facilitando el despliegue consistente en diferentes entornos.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/dockerfile\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> specifies the base <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/image\/\" target=\"_blank\">imagen<\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> for the <span class=\"glossaryai-tooltip glossary-term-650\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/container\/\" target=\"_blank\">contenedor<\/a><\/span><span class=\"gai-content-hidden glossaryai-tooltip-content\"><span class=\"gai-tooltip-body\"><span class=\"glossaryai-tooltip-text\">Containers are lightweight, portable units that encapsulate software and its dependencies, enabling consistent execution across different environments. They leverage OS-level virtualization for efficiency.<span class=\"glossaryai-more-link\"> <a href=\"https:\/\/dockerpros.com\/es\/wiki\/container\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span>. It sets the initial environment and determines layers for subsequent commands, crucial for efficient <span class=\"glossaryai-tooltip glossary-term-651\"><span class=\"glossaryai-link\"><a href=\"https:\/\/dockerpros.com\/es\/wiki\/image\/\" target=\"_blank\">imagen<\/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\/es\/wiki\/image\/\">More \u00bb<\/a><\/span><\/span><\/span><\/span><\/span> builds.<\/p>","protected":false},"author":1,"featured_media":1931,"parent":0,"template":"","glossary-cat":[],"class_list":["post-1307","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>Dockerfile FROM - 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\/es\/wiki\/dockerfile-from\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Dockerfile FROM - Dockerpros\" \/>\n<meta property=\"og:description\" content=\"The &quot;FROM&quot; instruction in a Dockerfile specifies the base image for the container. It sets the initial environment and determines layers for subsequent commands, crucial for efficient image builds.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/dockerpros.com\/es\/wiki\/dockerfile-from\/\" \/>\n<meta property=\"og:site_name\" content=\"Dockerpros\" \/>\n<meta property=\"article:modified_time\" content=\"2024-07-23T12:22:58+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.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=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/\",\"url\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/\",\"name\":\"Dockerfile FROM - Dockerpros\",\"isPartOf\":{\"@id\":\"https:\/\/dockerpros.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg\",\"datePublished\":\"2024-07-23T12:20:09+00:00\",\"dateModified\":\"2024-07-23T12:22:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage\",\"url\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg\",\"contentUrl\":\"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg\",\"width\":800,\"height\":600,\"caption\":\"dockerfile-from-2\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#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\":\"Dockerfile FROM\"}]},{\"@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\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/dockerpros.com\/#organization\",\"name\":\"Dockerpros\",\"url\":\"https:\/\/dockerpros.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@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":"Dockerfile FROM - Dockerpros\n\nEn este art\u00edculo, aprender\u00e1 sobre la instrucci\u00f3n FROM en el Dockerfile. La instrucci\u00f3n FROM es la primera instrucci\u00f3n no comentada en el Dockerfile. La instrucci\u00f3n FROM inicializa una nueva etapa de compilaci\u00f3n y establece la imagen base para instrucciones posteriores. Como tal, una instrucci\u00f3n FROM v\u00e1lida es necesaria para crear un Dockerfile.\n\nLa instrucci\u00f3n FROM puede aparecer varias veces dentro de un solo Dockerfile para crear m\u00faltiples im\u00e1genes o puede usar un artefacto de una etapa en otra etapa. Simplemente anote la \u00faltima imagen creada por cada instrucci\u00f3n FROM en la compilaci\u00f3n con un nombre de etapa usando la etiqueta AS. La imagen se crea o se extrae para la etapa especificada en FROM.\n\nSintaxis de FROM\n\nFROM  [AS ]\n\no\n\nFROM [:] [AS ]\n\no\n\nFROM [@] [AS ]\n\nEjemplo de FROM\n\nFROM ubuntu:16.04\n\nRUN apt-get update -y &amp;&amp; apt-get install -y python-pip python-dev build-essential\n\nCOPY . \/app\n\nWORKDIR \/app\n\nRUN pip install -r requirements.txt\n\nCMD [\"python\", \"app.py\"]\n\nEn el ejemplo anterior, la imagen base es ubuntu:16.04. Primero, actualiza el \u00edndice del paquete apt y luego instala los paquetes necesarios. Luego, copia el contenido del directorio actual en el directorio \/app de la imagen. Luego, establece el directorio de trabajo en \/app. Luego, instala los paquetes de Python necesarios. Finalmente, especifica el comando para ejecutar la aplicaci\u00f3n Python.\n\nEn resumen, la instrucci\u00f3n FROM es una instrucci\u00f3n esencial en el Dockerfile que establece la imagen base para instrucciones posteriores. Se puede usar varias veces dentro de un solo Dockerfile para crear m\u00faltiples im\u00e1genes o usar un artefacto de una etapa en otra etapa.","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\/es\/wiki\/dockerfile-from\/","og_locale":"es_ES","og_type":"article","og_title":"Dockerfile FROM - Dockerpros","og_description":"The \"FROM\" instruction in a Dockerfile specifies the base image for the container. It sets the initial environment and determines layers for subsequent commands, crucial for efficient image builds.","og_url":"https:\/\/dockerpros.com\/es\/wiki\/dockerfile-from\/","og_site_name":"Dockerpros","article_modified_time":"2024-07-23T12:22:58+00:00","og_image":[{"width":800,"height":600,"url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg","type":"image\/jpeg"}],"twitter_card":"summary_large_image","twitter_misc":{"Tiempo de lectura":"5 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/","url":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/","name":"Dockerfile FROM - Dockerpros\n\nEn este art\u00edculo, aprender\u00e1 sobre la instrucci\u00f3n FROM en el Dockerfile. La instrucci\u00f3n FROM es la primera instrucci\u00f3n no comentada en el Dockerfile. La instrucci\u00f3n FROM inicializa una nueva etapa de compilaci\u00f3n y establece la imagen base para instrucciones posteriores. Como tal, una instrucci\u00f3n FROM v\u00e1lida es necesaria para crear un Dockerfile.\n\nLa instrucci\u00f3n FROM puede aparecer varias veces dentro de un solo Dockerfile para crear m\u00faltiples im\u00e1genes o puede usar un artefacto de una etapa en otra etapa. Simplemente anote la \u00faltima imagen creada por cada instrucci\u00f3n FROM en la compilaci\u00f3n con un nombre de etapa usando la etiqueta AS. La imagen se crea o se extrae para la etapa especificada en FROM.\n\nSintaxis de FROM\n\nFROM  [AS ]\n\no\n\nFROM [:] [AS ]\n\no\n\nFROM [@] [AS ]\n\nEjemplo de FROM\n\nFROM ubuntu:16.04\n\nRUN apt-get update -y &amp;&amp; apt-get install -y python-pip python-dev build-essential\n\nCOPY . \/app\n\nWORKDIR \/app\n\nRUN pip install -r requirements.txt\n\nCMD [\"python\", \"app.py\"]\n\nEn el ejemplo anterior, la imagen base es ubuntu:16.04. Primero, actualiza el \u00edndice del paquete apt y luego instala los paquetes necesarios. Luego, copia el contenido del directorio actual en el directorio \/app de la imagen. Luego, establece el directorio de trabajo en \/app. Luego, instala los paquetes de Python necesarios. Finalmente, especifica el comando para ejecutar la aplicaci\u00f3n Python.\n\nEn resumen, la instrucci\u00f3n FROM es una instrucci\u00f3n esencial en el Dockerfile que establece la imagen base para instrucciones posteriores. Se puede usar varias veces dentro de un solo Dockerfile para crear m\u00faltiples im\u00e1genes o usar un artefacto de una etapa en otra etapa.","isPartOf":{"@id":"https:\/\/dockerpros.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage"},"image":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage"},"thumbnailUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg","datePublished":"2024-07-23T12:20:09+00:00","dateModified":"2024-07-23T12:22:58+00:00","breadcrumb":{"@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/dockerpros.com\/wiki\/dockerfile-from\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#primaryimage","url":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg","contentUrl":"https:\/\/dockerpros.com\/wp-content\/uploads\/2024\/07\/dockerfile-from_1307.jpg","width":800,"height":600,"caption":"dockerfile-from-2"},{"@type":"BreadcrumbList","@id":"https:\/\/dockerpros.com\/wiki\/dockerfile-from\/#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":"Dockerfile FROM"}]},{"@type":"WebSite","@id":"https:\/\/dockerpros.com\/#website","url":"https:\/\/dockerpros.com\/","name":"Profesionales de Docker","description":"DockerPros \u2013 Tu centro definitivo de recursos 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":"es"},{"@type":"Organization","@id":"https:\/\/dockerpros.com\/#organization","name":"Profesionales de Docker","url":"https:\/\/dockerpros.com\/","logo":{"@type":"ImageObject","inLanguage":"es","@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\/es\/wp-json\/wp\/v2\/glossary\/1307","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/users\/1"}],"version-history":[{"count":0,"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/glossary\/1307\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/media\/1931"}],"wp:attachment":[{"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/media?parent=1307"}],"wp:term":[{"taxonomy":"glossary-cat","embeddable":true,"href":"https:\/\/dockerpros.com\/es\/wp-json\/wp\/v2\/glossary-cat?post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}