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
Copy file name to clipboardExpand all lines: docs/tutorial/multi-container-apps/index.md
+28-3Lines changed: 28 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -38,7 +38,7 @@ For now, we will create the network first and attach the MySQL container at star
38
38
```
39
39
40
40
1. Start a MySQL container and attach it the network. We're also going to define a few environment variables that the
41
-
database will use to initialize the database (see the "Environment Variables" section in the [MySQL Docker Hub listing](https://hub.docker.com/_/mysql/)) (replace the ` \ ` characters with `` ` `` in Windows PowerShell).
41
+
database will use to initialize the database (see the "Environment Variables" section in the [MySQL Docker Hub listing](https://hub.docker.com/_/mysql/)).
42
42
43
43
```bash
44
44
docker run -d \
@@ -49,6 +49,17 @@ For now, we will create the network first and attach the MySQL container at star
49
49
mysql:5.7
50
50
```
51
51
52
+
If you are using PowerShell then use this command.
53
+
54
+
```powershell
55
+
docker run -d `
56
+
--network todo-app --network-alias mysql `
57
+
-v todo-mysql-data:/var/lib/mysql `
58
+
-e MYSQL_ROOT_PASSWORD=secret `
59
+
-e MYSQL_DATABASE=todos `
60
+
mysql:5.7
61
+
```
62
+
52
63
You'll also see we specified the `--network-alias` flag. We'll come back to that in just a moment.
53
64
54
65
!!! info "Pro-tip"
@@ -165,11 +176,11 @@ The todo app supports the setting of a few environment variables to specify MySQ
165
176
166
177
With all of that explained, let's start our dev-ready container!
167
178
168
-
1. We'll specify each of the environment variables above, as well as connect the container to our app network (replace the `\ ` characters with `````in Windows PowerShell).
179
+
1. We'll specify each of the environment variables above, as well as connect the container to our app network.
169
180
170
181
```bash hl_lines="3 4 5 6 7"
171
182
docker run -dp 3000:3000 \
172
-
-w /app -v ${PWD}:/app \
183
+
-w /app -v "$(pwd):/app" \
173
184
--network todo-app \
174
185
-e MYSQL_HOST=mysql \
175
186
-e MYSQL_USER=root \
@@ -179,6 +190,20 @@ With all of that explained, let's start our dev-ready container!
179
190
sh -c "yarn install && yarn run dev"
180
191
```
181
192
193
+
If you are using PowerShell then use this command.
194
+
195
+
```powershell hl_lines="3 4 5 6 7"
196
+
docker run -dp 3000:3000 `
197
+
-w /app -v "$(pwd):/app"`
198
+
--network todo-app `
199
+
-e MYSQL_HOST=mysql `
200
+
-e MYSQL_USER=root `
201
+
-e MYSQL_PASSWORD=secret `
202
+
-e MYSQL_DB=todos `
203
+
node:12-alpine `
204
+
sh -c "yarn install && yarn run dev"
205
+
```
206
+
182
207
1. If we look at the logs for the container (`docker logs <container-id>`), we should see a message indicating it's
Copy file name to clipboardExpand all lines: docs/tutorial/using-docker-compose/index.md
+29-4Lines changed: 29 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,11 +49,11 @@ And now, we'll start migrating a service at a time into the compose file.
49
49
50
50
## Defining the App Service
51
51
52
-
To remember, this was the command we were using to define our app container (replace the `\ ` characters with `` ` `` in Windows PowerShell).
52
+
To remember, this was the command we were using to define our app container.
53
53
54
54
```bash
55
55
docker run -dp 3000:3000 \
56
-
-w /app -v ${PWD}:/app \
56
+
-w /app -v "$(pwd):/app" \
57
57
--network todo-app \
58
58
-e MYSQL_HOST=mysql \
59
59
-e MYSQL_USER=root \
@@ -63,6 +63,20 @@ docker run -dp 3000:3000 \
63
63
sh -c "yarn install && yarn run dev"
64
64
```
65
65
66
+
If you are using PowerShell then use this command.
67
+
68
+
```powershell
69
+
docker run -dp 3000:3000 `
70
+
-w /app -v "$(pwd):/app" `
71
+
--network todo-app `
72
+
-e MYSQL_HOST=mysql `
73
+
-e MYSQL_USER=root `
74
+
-e MYSQL_PASSWORD=secret `
75
+
-e MYSQL_DB=todos `
76
+
node:12-alpine `
77
+
sh -c "yarn install && yarn run dev"
78
+
```
79
+
66
80
1. First, let's define the service entry and the image for the container. We can pick any name for the service.
67
81
The name will automatically become a network alias, which will be useful when defining our MySQL service.
68
82
@@ -102,7 +116,7 @@ docker run -dp 3000:3000 \
102
116
- 3000:3000
103
117
```
104
118
105
-
1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v ${PWD}:/app`) by using
119
+
1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v "$(pwd):/app"`) by using
106
120
the `working_dir` and `volumes` definitions. Volumes also has a [short](https://docs.docker.com/compose/compose-file/#short-syntax-3) and [long](https://docs.docker.com/compose/compose-file/#long-syntax-3) syntax.
107
121
108
122
One advantage of Docker Compose volume definitions is we can use relative paths from the current directory.
@@ -145,7 +159,7 @@ docker run -dp 3000:3000 \
145
159
146
160
### Defining the MySQL Service
147
161
148
-
Now, it's time to define the MySQL service. The command that we used for that container was the following (replace the ` \ ` characters with `` ` `` in Windows PowerShell):
162
+
Now, it's time to define the MySQL service. The command that we used for that container was the following:
149
163
150
164
```bash
151
165
docker run -d \
@@ -156,6 +170,17 @@ docker run -d \
156
170
mysql:5.7
157
171
```
158
172
173
+
If you are using PowerShell then use this command.
174
+
175
+
```powershell
176
+
docker run -d `
177
+
--network todo-app --network-alias mysql `
178
+
-v todo-mysql-data:/var/lib/mysql `
179
+
-e MYSQL_ROOT_PASSWORD=secret `
180
+
-e MYSQL_DATABASE=todos `
181
+
mysql:5.7
182
+
```
183
+
159
184
1. We will first define the new service and name it `mysql` so it automatically gets the network alias. We'll
0 commit comments