You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!--Delete sections as needed -->
## Description
Current issues:
- There are several `package.json` files, so it's ambiguous.
- There is already a `Dockerfile`, so it must be deleted if asking the
user to create one. Also, the existing Dockerfile has a different image
version than the one the user is asked to create.
Fixes:
- Added step to explore the existing Dockerfile to have a smoother
transition into deleting it.
- Added step to delete the Dockerfile.
- Updated step to specify the exact folder where to create the new
Dockerfile.
https://deploy-preview-23478--docsdocker.netlify.app/get-started/docker-concepts/building-images/writing-a-dockerfile/#creating-the-dockerfile
## Related issues or tickets
https://docker.slack.com/archives/C04BMTUC41E/p1759261212446019
## Reviews
<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->
- [ ] Editorial review
---------
Signed-off-by: Craig <[email protected]>
Copy file name to clipboardExpand all lines: content/get-started/docker-concepts/building-images/writing-a-dockerfile.md
+17-6Lines changed: 17 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,38 +79,49 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
79
79
80
80
1.[Download and install](https://www.docker.com/products/docker-desktop/) Docker Desktop.
81
81
82
-
2. Create a file named `Dockerfile` in the same folder as the file `package.json`.
82
+
2. Examine the project.
83
+
84
+
Explore the contents of `getting-started-todo-app/app/`. You'll notice that a
85
+
`Dockerfile` already exists. It is a simple text file that you can open in
86
+
any text or code editor.
87
+
88
+
3. Delete the existing `Dockerfile`.
89
+
90
+
For this exercise, you'll pretend you're starting from scratch and will
91
+
create a new `Dockerfile`.
92
+
93
+
4. Create a file named `Dockerfile` in the `getting-started-todo-app/app/` folder.
83
94
84
95
> **Dockerfile file extensions**
85
96
>
86
97
> It's important to note that the `Dockerfile` has _no_ file extension. Some editors
87
98
> will automatically add an extension to the file (or complain it doesn't have one).
88
99
89
-
3. In the `Dockerfile`, define your base image by adding the following line:
100
+
5. In the `Dockerfile`, define your base image by adding the following line:
90
101
91
102
```dockerfile
92
103
FROM node:22-alpine
93
104
```
94
105
95
-
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.
106
+
6. 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.
96
107
97
108
```dockerfile
98
109
WORKDIR /app
99
110
```
100
111
101
-
5. Copy all of the files from your project on your machine into the container image by using the `COPY` instruction:
112
+
7. Copy all of the files from your project on your machine into the container image by using the `COPY` instruction:
102
113
103
114
```dockerfile
104
115
COPY . .
105
116
```
106
117
107
-
6. Install the app's dependencies by using the `yarn` CLI and package manager. To do so, run a command using the `RUN` instruction:
118
+
8. Install the app's dependencies by using the `yarn` CLI and package manager. To do so, run a command using the `RUN` instruction:
108
119
109
120
```dockerfile
110
121
RUN yarn install --production
111
122
```
112
123
113
-
7. Finally, specify the default command to run by using the `CMD` instruction:
124
+
9. Finally, specify the default command to run by using the `CMD` instruction:
0 commit comments