Skip to content

Commit adc8d38

Browse files
authored
Merge pull request #24413 from docker/agent/issue-24394
docs: address issue #24394
2 parents 97f394b + 3e21d7c commit adc8d38

File tree

1 file changed

+57
-58
lines changed

1 file changed

+57
-58
lines changed

content/get-started/introduction/develop-with-containers.md

Lines changed: 57 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ summary: |
99
seamless integration and testing.
1010
weight: 2
1111
aliases:
12-
- /guides/getting-started/develop-with-containers/
12+
- /guides/getting-started/develop-with-containers/
1313
---
1414

1515
{{< youtube-embed D0SDBrS3t9I >}}
@@ -26,37 +26,33 @@ Now that you have Docker Desktop installed, you are ready to do some application
2626

2727
In this hands-on guide, you'll learn how to develop with containers.
2828

29-
3029
## Start the project
3130

3231
1. To get started, either clone or [download the project as a ZIP file](https://github.com/docker/getting-started-todo-app/archive/refs/heads/main.zip) to your local machine.
3332

34-
```console
35-
$ git clone https://github.com/docker/getting-started-todo-app
36-
```
33+
```console
34+
$ git clone https://github.com/docker/getting-started-todo-app
35+
```
3736

38-
And after the project is cloned, navigate into the new directory created by the clone:
37+
And after the project is cloned, navigate into the new directory created by the clone:
3938

40-
```console
41-
$ cd getting-started-todo-app
42-
```
39+
```console
40+
$ cd getting-started-todo-app
41+
```
4342

4443
2. Once you have the project, start the development environment using Docker Compose.
4544

46-
47-
To start the project using the CLI, run the following command:
45+
To start the project using the CLI, run the following command:
4846

4947
```console
5048
$ docker compose watch
5149
```
5250

5351
You will see an output that shows container images being pulled down, containers starting, and more. Don't worry if you don't understand it all at this point. But, within a moment or two, things should stabilize and finish.
5452

55-
5653
3. Open your browser to [http://localhost](http://localhost) to see the application up and running. It may take a few minutes for the app to run. The app is a simple to-do application, so feel free to add an item or two, mark some as done, or even delete an item.
5754

58-
![Screenshot of the getting started to-do app after its first launch](images/develop-getting-started-app-first-launch.webp)
59-
55+
![Screenshot of the getting started to-do app after its first launch](images/develop-getting-started-app-first-launch.webp)
6056

6157
### What's in the environment?
6258

@@ -70,7 +66,6 @@ Now that the environment is up and running, what's actually in it? At a high-lev
7066

7167
With this environment, you as the developer don’t need to install or configure any services, populate a database schema, configure database credentials, or anything. You only need Docker Desktop. The rest just works.
7268

73-
7469
## Make changes to the app
7570

7671
With this environment up and running, you’re ready to make a few changes to the application and see how Docker helps provide a fast feedback loop.
@@ -79,85 +74,90 @@ With this environment up and running, you’re ready to make a few changes to th
7974

8075
The greeting at the top of the page is populated by an API call at `/api/greeting`. Currently, it always returns "Hello world!". You’ll now modify it to return one of three randomized messages (that you'll get to choose).
8176

82-
1. Open the `backend/src/routes/getGreeting.js` file in a text editor. This file provides the handler for the API endpoint.
77+
1. Open the `backend/src/routes/getGreeting.js` file in a text editor on
78+
your local machine (in the cloned project directory). This file provides
79+
the handler for the API endpoint. Your changes will automatically sync to
80+
the running container.
8381

8482
2. Modify the variable at the top to an array of greetings. Feel free to use the following modifications or customize it to your own liking. Also, update the endpoint to send a random greeting from this list.
8583

86-
```js {linenos=table,hl_lines=["1-5",9],linenostart=1}
87-
const GREETINGS = [
88-
"Whalecome!",
89-
"All hands on deck!",
90-
"Charting the course ahead!",
91-
];
92-
93-
module.exports = async (req, res) => {
94-
res.send({
95-
greeting: GREETINGS[ Math.floor( Math.random() * GREETINGS.length )],
96-
});
97-
};
98-
```
84+
```js {linenos=table,hl_lines=["1-5",9],linenostart=1}
85+
const GREETINGS = [
86+
"Whalecome!",
87+
"All hands on deck!",
88+
"Charting the course ahead!",
89+
];
90+
91+
module.exports = async (req, res) => {
92+
res.send({
93+
greeting: GREETINGS[Math.floor(Math.random() * GREETINGS.length)],
94+
});
95+
};
96+
```
9997

10098
3. If you haven't done so yet, save the file. If you refresh your browser, you should see a new greeting. If you keep refreshing, you should see all of the messages appear.
10199

102-
![Screenshot of the to-do app with a new greeting](images/develop-app-with-greetings.webp)
103-
100+
![Screenshot of the to-do app with a new greeting](images/develop-app-with-greetings.webp)
104101

105102
### Change the placeholder text
106103

107104
When you look at the app, you'll see the placeholder text is simply "New Item". You’ll now make that a little more descriptive and fun. You’ll also make a few changes to the styling of the app too.
108105

109-
1. Open the `client/src/components/AddNewItemForm.jsx` file. This provides the component to add a new item to the to-do list.
106+
1. Open the `client/src/components/AddNewItemForm.jsx` file in your local
107+
project directory. This provides the component to add a new item to the
108+
to-do list.
110109

111110
2. Modify the `placeholder` attribute of the `Form.Control` element to whatever you'd like to display.
112111

113-
```js {linenos=table,hl_lines=[5],linenostart=33}
114-
<Form.Control
115-
value={newItem}
116-
onChange={(e) => setNewItem(e.target.value)}
117-
type="text"
118-
placeholder="What do you need to do?"
119-
aria-label="New item"
120-
/>
121-
```
112+
```js {linenos=table,hl_lines=[5],linenostart=33}
113+
<Form.Control
114+
value={newItem}
115+
onChange={(e) => setNewItem(e.target.value)}
116+
type="text"
117+
placeholder="What do you need to do?"
118+
aria-label="New item"
119+
/>
120+
```
122121

123122
3. Save the file and go back to your browser. You should see the change already hot-reloaded into your browser. If you don't like it, feel free to tweak it until it looks just right.
124123

125124
![Screenshot of the to-do app with an updated placeholder in the add item text field"](images/develop-app-with-updated-placeholder.webp)
126125

127-
128126
### Change the background color
129127

130128
Before you consider the application finalized, you need to make the colors better.
131129

132-
1. Open the `client/src/index.scss` file.
130+
1. Open the `client/src/index.scss` file in your local project directory.
133131

134132
2. Adjust the `background-color` attribute to any color you'd like. The provided snippet is a soft blue to go along with Docker's nautical theme.
135133

136-
If you're using an IDE, you can pick a color using the integrated color pickers. Otherwise, feel free to use an online [Color Picker](https://www.w3schools.com/colors/colors_picker.asp).
137-
138-
```css {linenos=table,hl_lines=2,linenostart=3}
139-
body {
140-
background-color: #99bbff;
141-
margin-top: 50px;
142-
font-family: 'Lato';
143-
}
144-
```
145-
146-
Each save should let you see the change immediately in the browser. Keep adjusting it until it's the perfect setup for you.
134+
If you're using an IDE, you can pick a color using the integrated color pickers. Otherwise, feel free to use an online [Color Picker](https://www.w3schools.com/colors/colors_picker.asp).
147135

136+
```css {linenos=table,hl_lines=2,linenostart=3}
137+
body {
138+
background-color: #99bbff;
139+
margin-top: 50px;
140+
font-family: "Lato";
141+
}
142+
```
148143

149-
![Screenshot of the to-do app with a new placeholder and background color"](images/develop-app-with-updated-client.webp)
144+
Each save should let you see the change immediately in the browser. Keep adjusting it until it's the perfect setup for you.
150145

151-
And with that, you're done. Congrats on updating your website.
146+
![Screenshot of the to-do app with a new placeholder and background color"](images/develop-app-with-updated-client.webp)
152147

148+
And with that, you're done. Congrats on updating your website.
153149

154150
## Recap
155151

156152
Before you move on, take a moment and reflect on what happened here. Within a few moments, you were able to:
157153

158154
- Start a complete development project with zero installation effort. The containerized environment provided the development environment, ensuring you have everything you need. You didn't have to install Node, MySQL, or any of the other dependencies directly on your machine. All you needed was Docker Desktop and a code editor.
159155

160-
- Make changes and see them immediately. This was made possible because 1) the processes running in each container are watching and responding to file changes and 2) the files are shared with the containerized environment.
156+
- Make changes and see them immediately. This was made possible because
157+
1. the processes running in each container are watching and responding to
158+
file changes and 2) the files in your local project directory are shared
159+
with the containerized environment, so edits you make locally are
160+
automatically synced to the containers.
161161

162162
Docker Desktop enables all of this and so much more. Once you start thinking with containers, you can create almost any environment and easily share it with your team.
163163

@@ -166,4 +166,3 @@ Docker Desktop enables all of this and so much more. Once you start thinking wit
166166
Now that the application has been updated, you’re ready to learn about packaging it as a container image and pushing it to a registry, specifically Docker Hub.
167167

168168
{{< button text="Build and push your first image" url="build-and-push-first-image" >}}
169-

0 commit comments

Comments
 (0)