Skip to content

Commit 88ef79f

Browse files
get-started: update write a dockerfile (#23478)
<!--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]>
1 parent f5a5477 commit 88ef79f

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

content/get-started/docker-concepts/building-images/writing-a-dockerfile.md

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,38 +79,49 @@ Now that you have the project, you’re ready to create the `Dockerfile`.
7979

8080
1. [Download and install](https://www.docker.com/products/docker-desktop/) Docker Desktop.
8181

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.
8394

8495
> **Dockerfile file extensions**
8596
>
8697
> It's important to note that the `Dockerfile` has _no_ file extension. Some editors
8798
> will automatically add an extension to the file (or complain it doesn't have one).
8899
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:
90101

91102
```dockerfile
92103
FROM node:22-alpine
93104
```
94105

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.
96107

97108
```dockerfile
98109
WORKDIR /app
99110
```
100111

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:
102113

103114
```dockerfile
104115
COPY . .
105116
```
106117

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:
108119
109120
```dockerfile
110121
RUN yarn install --production
111122
```
112123
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:
114125
115126
```dockerfile
116127
CMD ["node", "./src/index.js"]

0 commit comments

Comments
 (0)