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
Replacing Yarn with npm in Docker Workshop (#24012)
- replace old Docker desktop screenshot with the new sidebar
- Remove all references to Yarn in the explanation for Part 1
- Show new project directory structure for getting-started-repo
- Remove PWD reference from Part 3
- Remove all occurances of Yarn in Part 7 and 8
<!--Delete sections as needed -->
## Description
<!-- Tell us what you did and why -->
## Related issues or tickets
<!-- Related issues, pull requests, or Jira tickets -->
## Reviews
This PR is heavily dependent upon
docker/getting-started-app#98
<!-- Notes for reviewers here -->
<!-- List applicable reviews (optionally @tag reviewers) -->
- [ ] Technical review
- [ ] Editorial review
- [ ] Product review
---------
Co-authored-by: Craig Osterhout <craig.osterhout@docker.com>
Copy file name to clipboardExpand all lines: content/get-started/workshop/02_our_app.md
+12-9Lines changed: 12 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,10 +42,10 @@ Before you can run the application, you need to get the application source code
42
42
├── getting-started-app/
43
43
│ ├── .dockerignore
44
44
│ ├── package.json
45
+
│ ├── package-lock.json
45
46
│ ├── README.md
46
47
│ ├── spec/
47
48
│ ├── src/
48
-
│ └── yarn.lock
49
49
```
50
50
51
51
## Build the app's image
@@ -58,18 +58,21 @@ To build the image, you'll need to use a Dockerfile. A Dockerfile is simply a te
58
58
```dockerfile
59
59
# syntax=docker/dockerfile:1
60
60
61
-
FROM node:lts-alpine
61
+
FROM node:24-alpine
62
62
WORKDIR /app
63
63
COPY . .
64
-
RUNyarn install --production
64
+
RUNnpm install --omit=dev
65
65
CMD ["node", "src/index.js"]
66
66
EXPOSE 3000
67
67
```
68
+
This Dockerfile does the following:
68
69
69
-
This Dockerfile starts off with a `node:lts-alpine` base image, a
70
-
light-weight Linux image that comes with Node.js and the Yarn package
71
-
manager pre-installed. It copies all of the source code into the image,
72
-
installs the necessary dependencies, and starts the application.
70
+
- Uses `node:24-alpine` as the base image, a lightweight Linux image with Node.js pre-installed
71
+
- Sets `/app` as the working directory
72
+
- Copies source code into the image
73
+
- Installs the necessary dependencies
74
+
- Specifies the command to start the application
75
+
- Documents that the app listens on port 3000
73
76
74
77
2. Build the image using the following commands:
75
78
@@ -85,9 +88,9 @@ To build the image, you'll need to use a Dockerfile. A Dockerfile is simply a te
85
88
$ docker build -t getting-started .
86
89
```
87
90
88
-
The `docker build` command uses the Dockerfile to build a new image. You might have noticed that Docker downloaded a lot of "layers". This is because you instructed the builder that you wanted to start from the `node:lts-alpine` image. But, since you didn't have that on your machine, Docker needed to download the image.
91
+
The `docker build` command uses the Dockerfile to build a new image. You might have noticed that Docker downloaded a lot of "layers". This is because you instructed the builder that you wanted to start from the `node:24-alpine` image. But, since you didn't have that on your machine, Docker needed to download the image.
89
92
90
-
After Docker downloaded the image, the instructions from the Dockerfile copied in your application and used `yarn` to install your application's dependencies. The `CMD` directive specifies the default command to run when starting a container from this image.
93
+
After Docker downloaded the image, the instructions from the Dockerfile copied in your application and used `npm` to install your application's dependencies.
91
94
92
95
Finally, the `-t` flag tags your image. Think of this as a human-readable name for the final image. Since you named the image `getting-started`, you can refer to that image when you run a container.
Copy file name to clipboardExpand all lines: content/get-started/workshop/04_sharing_app.md
+1-49Lines changed: 1 addition & 49 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -81,55 +81,7 @@ Let's try to push the image to Docker Hub.
81
81
82
82
## Run the image on a new instance
83
83
84
-
Now that your image has been built and pushed into a registry, try running your app on a brand
85
-
new instance that has never seen this container image. To do this, you will use Play with Docker.
86
-
87
-
> [!NOTE]
88
-
>
89
-
> Play with Docker uses the amd64 platform. If you are using an ARM based Mac with Apple silicon, you will need to rebuild the image to be compatible with Play with Docker and push the new image to your repository.
90
-
>
91
-
> To build an image for the amd64 platform, use the `--platform` flag.
> Docker buildx also supports building multi-platform images. To learn more, see [Multi-platform images](/manuals/build/building/multi-platform.md).
97
-
98
-
99
-
1. Open your browser to [Play with Docker](https://labs.play-with-docker.com/).
100
-
101
-
2. Select **Login** and then select **docker** from the drop-down list.
102
-
103
-
3. Sign in with your Docker Hub account and then select **Start**.
104
-
105
-
4. Select the **ADD NEW INSTANCE** option on the left side bar. If you don't see it, make your browser a little wider. After a few seconds, a terminal window opens in your browser.
106
-
107
-

108
-
109
-
5. In the terminal, start your freshly pushed app.
110
-
111
-
```console
112
-
$ docker run -dp 0.0.0.0:3000:3000 YOUR-USER-NAME/getting-started
113
-
```
114
-
115
-
You should see the image get pulled down and eventually start up.
116
-
117
-
> [!TIP]
118
-
>
119
-
> You may have noticed that this command binds the port mapping to a
120
-
> different IP address. Previous `docker run` commands published ports to
121
-
> `127.0.0.1:3000` on the host. This time, you're using `0.0.0.0`.
122
-
>
123
-
> Binding to `127.0.0.1` only exposes a container's ports to the loopback
124
-
> interface. Binding to `0.0.0.0`, however, exposes the container's port
125
-
> on all interfaces of the host, making it available to the outside world.
126
-
>
127
-
> For more information about how port mapping works, see
If the 3000 badge doesn't appear, you can select **Open Port** and specify `3000`.
84
+
Now that your image has been built and pushed into a registry, you can run your app on any machine that has Docker installed. Try pulling and running your image on another computer or a cloud instance.
0 commit comments