Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
2. In the `Dockerfile`, define your base image by adding the following line:

```dockerfile
FROM eclipse-temurin:21.0.2_13-jdk-jammy
FROM eclipse-temurin:21.0.8_9-jdk-jammy
```

3. Now, define the working directory by using the `WORKDIR` instruction. This will specify where future commands will run and the directory files will be copied inside the container image.
Expand Down Expand Up @@ -190,7 +190,7 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
And with that, you should have the following Dockerfile:

```dockerfile
FROM eclipse-temurin:21.0.2_13-jdk-jammy
FROM eclipse-temurin:21.0.8_9-jdk-jammy
WORKDIR /app
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
Expand Down Expand Up @@ -268,15 +268,15 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
1. Consider the following Dockerfile:

```dockerfile
FROM eclipse-temurin:21.0.2_13-jdk-jammy AS builder
FROM eclipse-temurin:21.0.8_9-jdk-jammy AS builder
WORKDIR /opt/app
COPY .mvn/ .mvn
COPY mvnw pom.xml ./
RUN ./mvnw dependency:go-offline
COPY ./src ./src
RUN ./mvnw clean install

FROM eclipse-temurin:21.0.2_13-jre-jammy AS final
FROM eclipse-temurin:21.0.8_9-jre-jammy AS final
WORKDIR /opt/app
EXPOSE 8080
COPY --from=builder /opt/app/target/*.jar /opt/app/*.jar
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Consider the following Dockerfile that you created for the [getting-started](./w


```dockerfile
FROM node:20-alpine
FROM node:22-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
Expand Down Expand Up @@ -69,7 +69,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti


```dockerfile
FROM node:20-alpine
FROM node:22-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
Expand Down Expand Up @@ -121,20 +121,23 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti


<table>
<tr>
<td>Steps
</td>
<td>Description
</td>
<td>Time Taken(1st Run)
</td>
<td>Time Taken (2nd Run)
</td>
</tr>
<thead>
<tr>
<th>Steps
</th>
<th>Description
</th>
<th>Time Taken (1st Run)
</th>
<th>Time Taken (2nd Run)
</th>
</tr>
</thead>
<tbody>
<tr>
<td>1
</td>
<td>Load build definition from Dockerfile
<td><code>Load build definition from Dockerfile</code>
</td>
<td>0.0 seconds
</td>
Expand All @@ -144,7 +147,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>2
</td>
<td>Load metadata for docker.io/library/node:20-alpine
<td><code>Load metadata for docker.io/library/node:22-alpine</code>
</td>
<td>2.7 seconds
</td>
Expand All @@ -154,7 +157,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>3
</td>
<td>Load .dockerignore
<td><code>Load .dockerignore</code>
</td>
<td>0.0 seconds
</td>
Expand All @@ -164,7 +167,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>4
</td>
<td>Load build context
<td><code>Load build context</code>
<p>
(Context size: 4.60MB)
</td>
Expand All @@ -176,7 +179,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>5
</td>
<td>Set the working directory (WORKDIR)
<td><code>Set the working directory (WORKDIR)</code>
</td>
<td>0.1 seconds
</td>
Expand All @@ -186,7 +189,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>6
</td>
<td>Copy the local code into the container
<td><code>Copy the local code into the container</code>
</td>
<td>0.0 seconds
</td>
Expand All @@ -196,7 +199,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>7
</td>
<td>Run yarn install --production
<td><code>Run yarn install --production</code>
</td>
<td>10.0 seconds
</td>
Expand All @@ -206,7 +209,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>8
</td>
<td>Exporting layers
<td><code>Exporting layers</code>
</td>
<td>2.2 seconds
</td>
Expand All @@ -216,13 +219,14 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
<tr>
<td>9
</td>
<td>Exporting the final image
<td><code>Exporting the final image</code>
</td>
<td>3.0 seconds
</td>
<td>0.0 seconds
</td>
</tr>
</tbody>
</table>


Expand All @@ -233,7 +237,7 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
6. Update the Dockerfile to copy in the `package.json` file first, install dependencies, and then copy everything else in.

```dockerfile
FROM node:20-alpine
FROM node:22-alpine
WORKDIR /app
COPY package.json yarn.lock ./
RUN yarn install --production
Expand Down Expand Up @@ -262,10 +266,10 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
=> => transferring dockerfile: 175B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:21-alpine 0.0s
=> [internal] load metadata for docker.io/library/node:22-alpine 0.0s
=> [internal] load build context 0.8s
=> => transferring context: 53.37MB 0.8s
=> [1/5] FROM docker.io/library/node:21-alpine 0.0s
=> [1/5] FROM docker.io/library/node:22-alpine 0.0s
=> CACHED [2/5] WORKDIR /app 0.0s
=> [3/5] COPY package.json yarn.lock ./ 0.2s
=> [4/5] RUN yarn install --production 14.0s
Expand Down Expand Up @@ -295,10 +299,10 @@ In this hands-on guide, you will learn how to use the Docker build cache effecti
=> => transferring dockerfile: 37B 0.0s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [internal] load metadata for docker.io/library/node:21-alpine 0.0s
=> [internal] load metadata for docker.io/library/node:22-alpine 0.0s
=> [internal] load build context 0.2s
=> => transferring context: 450.43kB 0.2s
=> [1/5] FROM docker.io/library/node:21-alpine 0.0s
=> [1/5] FROM docker.io/library/node:22-alpine 0.0s
=> CACHED [2/5] WORKDIR /app 0.0s
=> CACHED [3/5] COPY package.json yarn.lock ./ 0.0s
=> CACHED [4/5] RUN yarn install --production 0.0s
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ A Dockerfile is a text-based document that's used to create a container image. I
As an example, the following Dockerfile would produce a ready-to-run Python application:

```dockerfile
FROM python:3.12
FROM python:3.13
WORKDIR /usr/local/app

# Install the application dependencies
Expand Down Expand Up @@ -69,7 +69,9 @@ In this quick hands-on guide, you'll write a Dockerfile that builds a simple Nod

### Set up

[Download this ZIP file](https://github.com/docker/getting-started-todo-app/raw/build-image-from-scratch/app.zip) and extract the contents into a directory on your machine.
[Download this ZIP file](https://github.com/docker/getting-started-todo-app/archive/refs/heads/build-image-from-scratch.zip) and extract the contents into a directory on your machine.

If you'd rather not download a ZIP file, clone the https://github.com/docker/getting-started-todo-app project and checkout the `build-image-from-scratch` branch.

### Creating the Dockerfile

Expand All @@ -87,7 +89,7 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
3. In the `Dockerfile`, define your base image by adding the following line:

```dockerfile
FROM node:20-alpine
FROM node:22-alpine
```

4. Now, define the working directory by using the `WORKDIR` instruction. This will specify where future commands will run and the directory files will be copied inside the container image.
Expand Down Expand Up @@ -117,7 +119,7 @@ Now that you have the project, you’re ready to create the `Dockerfile`.


```dockerfile
FROM node:20-alpine
FROM node:22-alpine
WORKDIR /app
COPY . .
RUN yarn install --production
Expand Down