103 Commits

Author SHA1 Message Date
Atomist Bot
37e489af74 Pin Docker image nginx:alpine
nginx:alpine
->
nginx:alpine@sha256:082f8c10bd47b6acc8ef15ae61ae45dd8fde0e9f389a8b5cb23c37408642bf5d

 [atomist:generated]
 [atomist-skill:atomist/docker-base-image-policy]

Signed-off-by: Atomist Bot <bot@atomist.com>
2022-10-07 07:12:42 +00:00
Atomist Bot
9d378893cb Pin Docker image node:12-alpine
node:12-alpine
->
node:12-alpine@sha256:d4b15b3d48f42059a15bd659be60afe21762aae9d6cbea6f124440895c27db68

 [atomist:generated]
 [atomist-skill:atomist/docker-base-image-policy]

Signed-off-by: Atomist Bot <bot@atomist.com>
2022-10-07 07:12:41 +00:00
Atomist Bot
113eea7de5 Pin Docker image python:alpine
python:alpine
->
python:alpine@sha256:c9d3c11e89887c82efeb4f4fee8771a406cf42f41aebbd23148906d5fe3c1426

 [atomist:generated]
 [atomist-skill:atomist/docker-base-image-policy]

Signed-off-by: Atomist Bot <bot@atomist.com>
2022-10-07 07:12:41 +00:00
Stefan Scherer
6f818a549f Merge pull request #295 from craig-osterhout/patch-1
Fix dead links
2022-08-30 14:55:19 +02:00
Craig Osterhout
cb16e5d1f3 Fix dead links
Fixed dead links that resulted in 404 errors.
 - https://docs.docker.com/docker-for-mac/dashboard/
 - https://docs.docker.com/docker-for-windows/dashboard/

Updated to a single link to https://docs.docker.com/desktop/
2022-08-16 10:43:20 -07:00
Stefan Scherer
7d6a447fca Merge pull request #255 from lunelson/lunelson/markdown-fixes
Fix some code fences and whitespace on "multi-container apps"
2022-04-11 17:00:51 +02:00
Stefan Scherer
0fdedec7a2 Merge branch 'master' into lunelson/markdown-fixes 2022-04-11 16:57:59 +02:00
Stefan Scherer
9a4c1b53dd Merge pull request #252 from pushparajbhatta/patch-1
Update index.md
2022-04-11 16:55:11 +02:00
Stefan Scherer
1fd29da9be Merge pull request #223 from geehon/master
support emoji
2022-04-11 16:53:42 +02:00
Stefan Scherer
2dac6361da Merge pull request #243 from yuuyins/issue-76-2
Fix #76
2022-04-11 16:48:15 +02:00
Stefan Scherer
858d6c7607 Merge pull request #249 from amims71/patch-1
fixed broken code design
2022-04-11 16:44:27 +02:00
Stefan Scherer
16d65a70fe Merge pull request #256 from docker/dependabot/npm_and_yarn/app/minimist-1.2.6
Bump minimist from 1.2.5 to 1.2.6 in /app
2022-04-11 16:40:59 +02:00
Stefan Scherer
664ad9edab Merge pull request #265 from spykard/master
Fix Build Error
2022-04-11 16:36:46 +02:00
Spyridon Kardakis
95a8d8a72b Fix Build Error #257 2022-04-04 15:20:17 +03:00
dependabot[bot]
d5044a9db7 Bump minimist from 1.2.5 to 1.2.6 in /app
Bumps [minimist](https://github.com/substack/minimist) from 1.2.5 to 1.2.6.
- [Release notes](https://github.com/substack/minimist/releases)
- [Commits](https://github.com/substack/minimist/compare/1.2.5...1.2.6)

---
updated-dependencies:
- dependency-name: minimist
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-03-26 06:13:18 +00:00
Lu Nelson
96670a1d03 fix code fences on multi-container doc 2022-03-21 11:37:25 +01:00
Pushpa Raj Bhatta
5abe931855 Update index.md
Bash code preview is breaking on line 75. Updated line 75 to it.
2022-02-26 00:41:12 +05:45
Amimul Ehshan
8801e0e0ca fixed broken code design 2022-02-18 19:26:51 +06:00
yuu
9b5581d3bd Fix #76
If the user runs that command "from the source code folder", i.e.
`getting-started`, docker will bind-mount getting-started to the
container's `/app`, which leads to error
`error Couldn't find a package.json file in "/app"`. It needs to bind
`getting-started/app` instead.
So, be explicit to the reader to be on the app source's directory
`getting-started/app` before running the command.
2022-02-12 01:35:40 -03:00
Stefan Scherer
798c396e89 Merge pull request #140 from tjmcewan/patch-1
Update dev mode command to install sqlite3 deps
2022-02-10 09:59:19 +01:00
Stefan Scherer
9eab81d81e Update index.md 2022-02-10 09:58:21 +01:00
Stefan Scherer
720eadbeae Merge pull request #242 from StefanScherer/revert-pr192
Revert "Update app.js"
2022-02-10 09:52:18 +01:00
Stefan Scherer
1bec479199 Revert "Update app.js"
This reverts commit 7bb2ef8c6d.
2022-02-10 09:36:44 +01:00
Stefan Scherer
2be5c745e8 Merge pull request #192 from aad84/patch-1
Update app.js
2022-02-10 09:28:26 +01:00
Stefan Scherer
8725352c3f Merge pull request #238 from lucasersson/patch-1
Update index.md
2022-02-09 12:19:45 +01:00
Stefan Scherer
f1f2012af5 Merge pull request #237 from ScottLozano/patch-2
Update index.md
2022-02-09 11:59:45 +01:00
Stefan Scherer
9ddebfdd36 Merge pull request #236 from ScottLozano/patch-1
Update index.md
2022-02-09 11:56:45 +01:00
lucasersson
9bf480301d Update index.md
updated readme to latest stable version of docker compose
2022-01-12 13:00:46 +01:00
Scott Lozano
d35fc60923 Update index.md 2022-01-05 00:55:18 -08:00
Scott Lozano
6ab1ec709f Update index.md 2022-01-05 00:17:24 -08:00
Stefan Scherer
56890c941a Merge pull request #226 from SosukeHosokawa/master
fix on 'Our Application' tutorial for Apple silicon
2021-12-02 18:25:08 +01:00
Stefan Scherer
e96065a503 Merge pull request #145 from antalvarenga/master
Multi-container apps: add workaround for non amd64 machines
2021-12-02 07:30:06 +01:00
SosukeHosokawa
5c1574e643 fix on 'Our application' tutorial for Apple silicon 2021-11-24 01:24:18 +09:00
GeeHon
b37be73687 support emoji 2021-11-16 12:20:43 +08:00
Stefan Scherer
42f8dbe70c Merge pull request #187 from ollyhowell/patch-1
Add reminder to save file for the app refresh change
2021-11-12 09:25:15 +01:00
Stefan Scherer
a1b127be03 Merge pull request #146 from ags1773/fix-test
fix: path to db file in test
2021-11-12 09:23:50 +01:00
Stefan Scherer
9bccc3cf99 Merge pull request #169 from paulhermanseu/patch-1
Update package.json
2021-11-12 09:15:13 +01:00
Stefan Scherer
5ded522cbf Merge pull request #90 from spicylentils/patch-3
Update docs/tutorial/using-bind-mounts/index.md
2021-11-12 08:31:17 +01:00
Stefan Scherer
ace32adb9d Merge pull request #120 from Patil2099/master
Point To The Correct Link For Play With Docker
2021-11-12 08:30:00 +01:00
Stefan Scherer
5572d7a5b3 Merge pull request #219 from docker/dependabot/pip/mkdocs-1.2.3
Bump mkdocs from 1.2.2 to 1.2.3
2021-11-12 08:28:11 +01:00
Stefan Scherer
572dc47f99 Merge pull request #126 from GomolemoOnGithub/patch-1
Period omission at the end of line 7,8 and 10.
2021-11-12 08:20:13 +01:00
Stefan Scherer
5c65399cec Merge pull request #113 from NicolaeTelescu/patch-1
Update index.md from using bind mount
2021-11-12 08:16:00 +01:00
dependabot[bot]
6086449d15 Bump mkdocs from 1.2.2 to 1.2.3
Bumps [mkdocs](https://github.com/mkdocs/mkdocs) from 1.2.2 to 1.2.3.
- [Release notes](https://github.com/mkdocs/mkdocs/releases)
- [Commits](https://github.com/mkdocs/mkdocs/compare/1.2.2...1.2.3)

---
updated-dependencies:
- dependency-name: mkdocs
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-11-12 07:04:04 +00:00
Stefan Scherer
5c00304375 Merge pull request #199 from sugamkarki/master
Removed body-parser as a dependency.
2021-11-12 08:03:35 +01:00
Stefan Scherer
0efc3a5c19 Merge pull request #218 from StefanScherer/faster-getting-started-guide
Faster getting started guide, fix for Apple silicon
2021-11-11 11:05:18 +01:00
Stefan Scherer
782d9421ae Add dependencies for Apple silicon / M1 / arm64 builds
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2021-11-10 16:27:07 +01:00
Stefan Scherer
d002206c3e Make getting started guide faster
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2021-11-10 16:27:06 +01:00
Stefan Scherer
e04817f421 Merge pull request #178 from zuccamia/update-reference-urls
Update reference links in docker compose section.
2021-11-10 09:50:31 +01:00
Stefan Scherer
0f44699cfa Merge pull request #196 from docker/dependabot/npm_and_yarn/app/tmpl-1.0.5
Bump tmpl from 1.0.4 to 1.0.5 in /app
2021-11-10 09:43:55 +01:00
Stefan Scherer
966b2e2857 Merge pull request #179 from docker/dependabot/npm_and_yarn/app/path-parse-1.0.7
Bump path-parse from 1.0.6 to 1.0.7 in /app
2021-11-10 09:43:30 +01:00
Stefan Scherer
de74d48616 Merge pull request #163 from catnuxer/docs-persisting-our-data
docs: Fix missing container id
2021-11-10 09:41:14 +01:00
Stefan Scherer
14c67643bb Merge pull request #212 from spenceradolph/master
Removed 'RUN apk add --no-cache python g++ make'
2021-11-10 08:40:35 +01:00
Spencer Adolph
acdcd83ced Removed 'RUN apk add --no-cache python g++ make'
This line did not appear to be necessary for the tutorial. Testing with it removed appeared to have no effect. Additionally, this line does not appear later in the tutorial when referring back to this step (see /docs/tutorial/image-building-best-practices/index.md).
2021-10-21 12:57:36 -05:00
Guillaume Lours
8511b9af07 Merge pull request #209 from docker/fix-security-issues
update javascript dependencies to fix security issues
2021-10-08 17:34:24 +02:00
Guillaume Lours
f2af4b0ae4 update javascript dependencies to fix security issues
Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
2021-10-08 17:31:47 +02:00
Guillaume Lours
7ceaaee2a7 Merge pull request #204 from atline/fix_dependency
Increase mkdoc version to 1.2.2.
2021-10-08 16:45:22 +02:00
atline
25f25d8126 Increase mkdoc version to 1.2.2.
python:alpine is now points to python3.10, with old mkdoc, it will reports:

```
from collections import Sequence, namedtuple
ImportError: cannot import name 'Sequence' from 'collections' (/usr/local/lib/python3.10/collections/__init__.py)
```

This is due to:
> Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated since Python 3.3, and in 3.10 it will stop working

Signed-off-by: atline <atline@aliyun.com>
2021-10-06 21:52:46 +08:00
magusikrak
8a8994297d removed bodyparser as a dependency 2021-09-29 00:09:39 +05:45
dependabot[bot]
4e7c2668fc Bump tmpl from 1.0.4 to 1.0.5 in /app
Bumps [tmpl](https://github.com/daaku/nodejs-tmpl) from 1.0.4 to 1.0.5.
- [Release notes](https://github.com/daaku/nodejs-tmpl/releases)
- [Commits](https://github.com/daaku/nodejs-tmpl/commits/v1.0.5)

---
updated-dependencies:
- dependency-name: tmpl
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-09-21 18:15:16 +00:00
aad84
7bb2ef8c6d Update app.js 2021-09-20 23:47:25 +05:30
Oliver Howell
433353af1c Add reminder to save file for the app refresh 2021-09-14 15:39:14 +01:00
dependabot[bot]
ac4adc8665 Bump path-parse from 1.0.6 to 1.0.7 in /app
Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2021-08-12 01:58:18 +00:00
Ngoc Hoang
67e75bb1cb Update reference links in docker compose section. 2021-08-11 21:49:23 +09:00
Paul Hermans
06d835a3cd Update package.json
sqlite3 version update needed
2021-07-12 16:34:43 +02:00
Chuli jimmi Manurung
9950c06246 docs: Fix missing container id 2021-06-13 21:39:07 +08:00
Amogh Sahasrabhojanee
8dd3914433 fix: path to db file in test 2021-05-08 10:50:38 +05:30
António Alvarenga
958126d5a7 add backtick 2021-05-07 11:33:02 +01:00
António Alvarenga
f390971d25 enclose code block in backticks 2021-05-07 11:31:51 +01:00
António Alvarenga
64a1666f12 Merge pull request #1 from antalvarenga/antalvarenga-patch-1
Multi-container apps: add workaround for non amd64 machines
2021-05-07 11:28:16 +01:00
António Alvarenga
5d5e551104 Multi-container apps: add workaround for non amd64 machines 2021-05-07 11:26:18 +01:00
Stefan Scherer
13386236e4 Merge pull request #134 from docker/dependabot/pip/pygments-2.7.4
Bump pygments from 2.6.1 to 2.7.4
2021-05-06 07:34:25 +02:00
Stefan Scherer
2376af82e7 Merge pull request #135 from docker/dependabot/npm_and_yarn/app/y18n-4.0.1
Bump y18n from 4.0.0 to 4.0.1 in /app
2021-05-06 07:30:51 +02:00
Tim McEwan
0edef34461 Update dev mode command to install sqlite3 deps 2021-04-30 17:59:29 +10:00
dependabot[bot]
e991a5ab73 Bump y18n from 4.0.0 to 4.0.1 in /app
Bumps [y18n](https://github.com/yargs/y18n) from 4.0.0 to 4.0.1.
- [Release notes](https://github.com/yargs/y18n/releases)
- [Changelog](https://github.com/yargs/y18n/blob/master/CHANGELOG.md)
- [Commits](https://github.com/yargs/y18n/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-31 15:30:29 +00:00
dependabot[bot]
62e2117581 Bump pygments from 2.6.1 to 2.7.4
Bumps [pygments](https://github.com/pygments/pygments) from 2.6.1 to 2.7.4.
- [Release notes](https://github.com/pygments/pygments/releases)
- [Changelog](https://github.com/pygments/pygments/blob/master/CHANGES)
- [Commits](https://github.com/pygments/pygments/compare/2.6.1...2.7.4)

Signed-off-by: dependabot[bot] <support@github.com>
2021-03-29 22:08:19 +00:00
Alex White
4b6b5476c5 Update README.md 2021-03-09 08:50:32 +00:00
zipperer
e43a605d37 Edit docs/tutorial/using-bind-mounts/index.md
'uses cases' |-> 'use cases'
2021-03-09 08:49:09 +00:00
Stefan Scherer
eccb882c59 Add build tools to fix arm64 build issue
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2021-03-09 08:47:47 +00:00
Moses
dbae842f9c Period omission at the end of line 7,8 and 10. The suggested bullet sign used "- " does not display
Am using google chrome browser Version 88.0.4324.190 (Official Build) (64-bit)
2021-03-02 07:51:54 +02:00
Pankaj Patil
dcfbefe0af Point To The Correct Link For Play With Docker 2021-02-12 23:26:42 +05:30
Telescu Nicolae
e9f8d4443a Update index.md
The command for bind mount doesn't run in Ubuntu if the user is not in the source code folder. At least, for me didn't work. So I specified that to prevent errors and bugs.
2021-01-20 11:06:02 +02:00
Stefan Scherer
3de6451f5c Merge pull request #104 from StefanScherer/build-arm64
Build amd64 and arm64 image
2020-12-10 19:42:46 +01:00
Stefan Scherer
b66f1c3224 Build amd64 and arm64 image
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2020-12-10 12:34:01 +01:00
Stephen Turner
23e02b9a44 Add section on vulnerability scanning (#98)
* Update index.md

* Add files via upload

* Update index.md

* Update docs/tutorial/image-building-best-practices/index.md

Co-authored-by: Usha Mandya <47779042+usha-mandya@users.noreply.github.com>

* Update index.md

Co-authored-by: Usha Mandya <47779042+usha-mandya@users.noreply.github.com>
2020-11-02 12:24:36 +00:00
dependabot[bot]
5cccd65849 Bump yargs-parser from 13.1.1 to 13.1.2 in /app
Bumps [yargs-parser](https://github.com/yargs/yargs-parser) from 13.1.1 to 13.1.2.
- [Release notes](https://github.com/yargs/yargs-parser/releases)
- [Changelog](https://github.com/yargs/yargs-parser/blob/master/docs/CHANGELOG-full.md)
- [Commits](https://github.com/yargs/yargs-parser/commits)

Signed-off-by: dependabot[bot] <support@github.com>
2020-10-22 14:54:02 +01:00
Tony Brown
9646231353 Update multi-container-apps env vars security typo 2020-10-22 09:07:54 +01:00
Tim Gibson
3cbe2e686e Update README.md 2020-10-22 09:04:31 +01:00
Stefan Scherer
172c616131 Merge pull request #81 from mat007/build-github-action
Add github action to build
2020-09-30 16:35:34 +02:00
spicylentils
a2932698bd Update docs/tutorial/using-bind-mounts/index.md
Fix confusing wording regarding sources and destinations
2020-09-28 17:01:39 -07:00
Stefan Scherer
6190776cb6 Merge pull request #77 from Fl4zher/fix-typo
fixing typo
2020-08-31 07:21:30 +02:00
Mathieu Champlon
3323acf03e Add github action to build
This makes sure the project builds correctly.
2020-08-27 11:01:06 +02:00
Stefan Scherer
559d5f335e Merge pull request #73 from veyndan/patch-1
Fix typo
2020-08-25 12:16:01 +02:00
Stefan Scherer
6916e6a595 Merge pull request #78 from coreygarvey/patch-1
Update docs w/ missing "to"
2020-08-25 12:14:38 +02:00
Corey Garvey
bb961ef28d Update docs w/ missing "to"
Missing word in the docs
2020-08-15 11:15:52 +01:00
Harun Kilic
0b402b3ebf fixing typo 2020-08-07 02:09:28 +02:00
Veyndan Stuart
4ed7232ea2 Fix typo 2020-08-01 20:45:52 +02:00
Stefan Scherer
9f31a47053 Merge pull request #72 from docker/dependabot/npm_and_yarn/app/lodash-4.17.19
Bump lodash from 4.17.15 to 4.17.19 in /app
2020-07-20 20:04:57 +02:00
dependabot[bot]
b1d106ea7c Bump lodash from 4.17.15 to 4.17.19 in /app
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.19.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.19)

Signed-off-by: dependabot[bot] <support@github.com>
2020-07-19 17:31:36 +00:00
Stefan Scherer
288a57ea63 Merge pull request #71 from StefanScherer/fix-jenkinsfile
Fix build command
2020-07-15 09:00:05 +02:00
Stefan Scherer
f232e36815 Fix build command
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2020-07-15 08:59:02 +02:00
Stefan Scherer
fe2686fe00 Merge pull request #70 from StefanScherer/powershell
Show multiline PowerShell commands
2020-07-15 08:55:44 +02:00
Stefan Scherer
a33ed89ab3 Quote volume mapping and use pwd
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2020-07-15 08:45:25 +02:00
Stefan Scherer
f77065be98 Show multiline PowerShell commands
Signed-off-by: Stefan Scherer <stefan.scherer@docker.com>
2020-07-15 08:20:44 +02:00
27 changed files with 2606 additions and 2780 deletions

12
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,12 @@
name: Build
on: [push, pull_request]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build
uses: docker/build-push-action@v1
with:
push: false

View File

@@ -1,23 +1,28 @@
# Install the base requirements for the app. # Install the base requirements for the app.
# This stage is to support development. # This stage is to support development.
FROM python:alpine AS base FROM python:alpine@sha256:c9d3c11e89887c82efeb4f4fee8771a406cf42f41aebbd23148906d5fe3c1426 AS base
WORKDIR /app WORKDIR /app
COPY requirements.txt . COPY requirements.txt .
RUN pip install -r requirements.txt RUN pip install -r requirements.txt
# Run tests to validate app FROM node:12-alpine@sha256:d4b15b3d48f42059a15bd659be60afe21762aae9d6cbea6f124440895c27db68 AS app-base
FROM node:12-alpine AS app-base
WORKDIR /app WORKDIR /app
COPY app/package.json app/yarn.lock ./ COPY app/package.json app/yarn.lock ./
RUN yarn install
COPY app/spec ./spec COPY app/spec ./spec
COPY app/src ./src COPY app/src ./src
# Run tests to validate app
FROM app-base AS test
RUN apk add --no-cache python3 g++ make
RUN yarn install
RUN yarn test RUN yarn test
# Clear out the node_modules and create the zip # Clear out the node_modules and create the zip
FROM app-base AS app-zip-creator FROM app-base AS app-zip-creator
RUN rm -rf node_modules && \ COPY app/package.json app/yarn.lock ./
apk add zip && \ COPY app/spec ./spec
COPY app/src ./src
RUN apk add zip && \
zip -r /app.zip /app zip -r /app.zip /app
# Dev-ready container - actual files will be mounted in # Dev-ready container - actual files will be mounted in
@@ -31,6 +36,6 @@ RUN mkdocs build
# Extract the static content from the build # Extract the static content from the build
# and use a nginx image to serve the content # and use a nginx image to serve the content
FROM nginx:alpine FROM nginx:alpine@sha256:082f8c10bd47b6acc8ef15ae61ae45dd8fde0e9f389a8b5cb23c37408642bf5d
COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip COPY --from=app-zip-creator /app.zip /usr/share/nginx/html/assets/app.zip
COPY --from=build /app/site /usr/share/nginx/html COPY --from=build /app/site /usr/share/nginx/html

2
Jenkinsfile vendored
View File

@@ -10,7 +10,7 @@ pipeline {
when { when {
branch 'master' branch 'master'
} }
sh "docker build docker/getting-started ." sh "docker build -t docker/getting-started ."
steps { steps {
withDockerRegistry([url: "", credentialsId: "dockerbuildbot-index.docker.io"]) { withDockerRegistry([url: "", credentialsId: "dockerbuildbot-index.docker.io"]) {

View File

@@ -37,6 +37,6 @@ docker-compose up
If you find typos or other issues with the tutorial, feel free to create a PR and suggest fixes! If you find typos or other issues with the tutorial, feel free to create a PR and suggest fixes!
If you have ideas on how to make the tutorial better or new content, please open an issue first before working on your idea. While we love input, we want to keep the tutorial is scoped to new-comers. If you have ideas on how to make the tutorial better or new content, please open an issue first before working on your idea. While we love input, we want to keep the tutorial scoped to newcomers.
As such, we may reject ideas for more advanced requests and don't want you to lose any work you might As such, we may reject ideas for more advanced requests and don't want you to lose any work you might
have done. So, ask first and we'll gladly hear your thoughts! have done. So, ask first and we'll gladly hear your thoughts!

View File

@@ -9,13 +9,15 @@
"dev": "nodemon src/index.js" "dev": "nodemon src/index.js"
}, },
"dependencies": { "dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1", "express": "^4.17.1",
"mysql": "^2.17.1", "mysql": "^2.17.1",
"sqlite3": "^4.1.0", "sqlite3": "^5.0.0",
"uuid": "^3.3.3", "uuid": "^3.3.3",
"wait-port": "^0.2.2" "wait-port": "^0.2.2"
}, },
"resolutions": {
"ansi-regex": "5.0.1"
},
"prettier": { "prettier": {
"trailingComma": "all", "trailingComma": "all",
"tabWidth": 4, "tabWidth": 4,
@@ -24,8 +26,8 @@
"singleQuote": true "singleQuote": true
}, },
"devDependencies": { "devDependencies": {
"jest": "^24.9.0", "jest": "^27.2.5",
"nodemon": "^1.19.2", "nodemon": "^2.0.13",
"prettier": "^1.18.2" "prettier": "^1.18.2"
} }
} }

View File

@@ -1,5 +1,6 @@
const db = require('../../src/persistence/sqlite'); const db = require('../../src/persistence/sqlite');
const fs = require('fs'); const fs = require('fs');
const location = process.env.SQLITE_DB_LOCATION || '/etc/todos/todo.db';
const ITEM = { const ITEM = {
id: '7aef3d7c-d301-4846-8358-2a91ec9d6be3', id: '7aef3d7c-d301-4846-8358-2a91ec9d6be3',
@@ -8,8 +9,8 @@ const ITEM = {
}; };
beforeEach(() => { beforeEach(() => {
if (fs.existsSync('/etc/todos/todo.db')) { if (fs.existsSync(location)) {
fs.unlinkSync('/etc/todos/todo.db'); fs.unlinkSync(location);
} }
}); });

View File

@@ -6,7 +6,7 @@ const addItem = require('./routes/addItem');
const updateItem = require('./routes/updateItem'); const updateItem = require('./routes/updateItem');
const deleteItem = require('./routes/deleteItem'); const deleteItem = require('./routes/deleteItem');
app.use(require('body-parser').json()); app.use(express.json());
app.use(express.static(__dirname + '/static')); app.use(express.static(__dirname + '/static'));
app.get('/items', getItems); app.get('/items', getItems);

View File

@@ -29,11 +29,12 @@ async function init() {
user, user,
password, password,
database, database,
charset: 'utf8mb4',
}); });
return new Promise((acc, rej) => { return new Promise((acc, rej) => {
pool.query( pool.query(
'CREATE TABLE IF NOT EXISTS todo_items (id varchar(36), name varchar(255), completed boolean)', 'CREATE TABLE IF NOT EXISTS todo_items (id varchar(36), name varchar(255), completed boolean) DEFAULT CHARSET utf8mb4',
err => { err => {
if (err) return rej(err); if (err) return rej(err);

File diff suppressed because it is too large Load Diff

View File

@@ -9,6 +9,6 @@ else
fi fi
docker buildx build \ docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm/v7,linux/arm/v6 \ --platform linux/amd64,linux/arm64 \
-t docker/getting-started:latest \ -t docker/getting-started:latest \
$( (( $WILL_PUSH == 1 )) && printf %s '--push' ) . $( (( $WILL_PUSH == 1 )) && printf %s '--push' ) .

Binary file not shown.

After

Width:  |  Height:  |  Size: 125 KiB

View File

@@ -1,3 +1,46 @@
## Security Scanning
When you have built an image, it is good practice to scan it for security vulnerabilities using the `docker scan` command.
Docker has partnered with [Snyk](http://snyk.io) to provide the vulnerability scanning service.
For example, to scan the `getting-started` image you created earlier in the tutorial, you can just type
```bash
docker scan getting-started
```
The scan uses a constantly updated database of vulnerabilities, so the output you see will vary as new
vulnerabilities are discovered, but it might look something like this:
```plaintext
✗ Low severity vulnerability found in freetype/freetype
Description: CVE-2020-15999
Info: https://snyk.io/vuln/SNYK-ALPINE310-FREETYPE-1019641
Introduced through: freetype/freetype@2.10.0-r0, gd/libgd@2.2.5-r2
From: freetype/freetype@2.10.0-r0
From: gd/libgd@2.2.5-r2 > freetype/freetype@2.10.0-r0
Fixed in: 2.10.0-r1
✗ Medium severity vulnerability found in libxml2/libxml2
Description: Out-of-bounds Read
Info: https://snyk.io/vuln/SNYK-ALPINE310-LIBXML2-674791
Introduced through: libxml2/libxml2@2.9.9-r3, libxslt/libxslt@1.1.33-r3, nginx-module-xslt/nginx-module-xslt@1.17.9-r1
From: libxml2/libxml2@2.9.9-r3
From: libxslt/libxslt@1.1.33-r3 > libxml2/libxml2@2.9.9-r3
From: nginx-module-xslt/nginx-module-xslt@1.17.9-r1 > libxml2/libxml2@2.9.9-r3
Fixed in: 2.9.9-r4
```
The output lists the type of vulnerability, a URL to learn more, and importantly which version of the relevant library
fixes the vulnerability.
There are several other options, which you can read about in the [docker scan documentation](https://docs.docker.com/engine/scan/).
As well as scanning your newly built image on the command line, you can also [configure Docker Hub](https://docs.docker.com/docker-hub/vulnerability-scanning/)
to scan all newly pushed images automatically, and you can then see the results in both Docker Hub and Docker Desktop.
![Hub vulnerability scanning](hvs.png){: style=width:75% }
{: .text-center }
## Image Layering ## Image Layering
@@ -222,6 +265,6 @@ into an nginx container. Cool, huh?
## Recap ## Recap
By understanding a little bit about how images are structured, we can build images faster and ship fewer changes. By understanding a little bit about how images are structured, we can build images faster and ship fewer changes.
Scanning images gives us confidence that the containers we are running and distributing are secure.
Multi-stage builds also help us reduce overall image size and increase final container security by separating Multi-stage builds also help us reduce overall image size and increase final container security by separating
build-time dependencies from runtime dependencies. build-time dependencies from runtime dependencies.

View File

@@ -25,19 +25,19 @@ You'll notice a few flags being used. Here's some more info on them:
docker run -dp 80:80 docker/getting-started docker run -dp 80:80 docker/getting-started
``` ```
## The VSCode Extension ## The Docker Dashboard
Before going too far, we want to highlight the Docker VSCode Extension, which gives Before going too far, we want to highlight the Docker Dashboard, which gives
you a quick view of the containers running on your machine. It gives you quick you a quick view of the containers running on your machine. It gives you quick
access to container logs, lets you get a shell inside the container, and lets you access to container logs, lets you get a shell inside the container, and lets you
easily manage container lifecycle (stop, remove, etc.). easily manage container lifecycle (stop, remove, etc.).
To access the extension, follow the instructions To access the dashboard, follow the instructions in the
[here](https://code.visualstudio.com/docs/containers/overview). If you open the extension [Docker Desktop manual](https://docs.docker.com/desktop/). If you open the dashboard
now, you will see this tutorial running! The container name (`angry_taussig` below) is a now, you will see this tutorial running! The container name (`jolly_bouman` below) is a
randomly created name. So, you'll most likely have a different name. randomly created name. So, you'll most likely have a different name.
![Tutorial container running in Docker Extension](vs-tutorial-in-extension.png) ![Tutorial container running in Docker Dashboard](tutorial-in-dashboard.png)
## What is a container? ## What is a container?

View File

@@ -4,12 +4,12 @@ application stack. The following question often arises - "Where will MySQL run?
container or run it separately?" In general, **each container should do one thing and do it well.** A few container or run it separately?" In general, **each container should do one thing and do it well.** A few
reasons: reasons:
- There's a good chance you'd have to scale APIs and front-ends differently than databases - There's a good chance you'd have to scale APIs and front-ends differently than databases.
- Separate containers let you version and update versions in isolation - Separate containers let you version and update versions in isolation.
- While you may use a container for the database locally, you may want to use a managed service - While you may use a container for the database locally, you may want to use a managed service
for the database in production. You don't want to ship your database engine with your app then. for the database in production. You don't want to ship your database engine with your app then.
- Running multiple processes will require a process manager (the container only starts one process), - Running multiple processes will require a process manager (the container only starts one process),
which adds complexity to container startup/shutdown which adds complexity to container startup/shutdown.
And there are more reasons. So, we will update our application to work like this: And there are more reasons. So, we will update our application to work like this:
@@ -37,8 +37,8 @@ For now, we will create the network first and attach the MySQL container at star
docker network create todo-app docker network create todo-app
``` ```
1. Start a MySQL container and attach it the network. We're also going to define a few environment variables that the 1. Start a MySQL container and attach it to the network. We're also going to define a few environment variables that the
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). database will use to initialize the database (see the "Environment Variables" section in the [MySQL Docker Hub listing](https://hub.docker.com/_/mysql/)).
```bash ```bash
docker run -d \ docker run -d \
@@ -49,6 +49,17 @@ For now, we will create the network first and attach the MySQL container at star
mysql:5.7 mysql:5.7
``` ```
If you are using PowerShell then use this command.
```powershell
docker run -d `
--network todo-app --network-alias mysql `
-v todo-mysql-data:/var/lib/mysql `
-e MYSQL_ROOT_PASSWORD=secret `
-e MYSQL_DATABASE=todos `
mysql:5.7
```
You'll also see we specified the `--network-alias` flag. We'll come back to that in just a moment. You'll also see we specified the `--network-alias` flag. We'll come back to that in just a moment.
!!! info "Pro-tip" !!! info "Pro-tip"
@@ -56,6 +67,20 @@ For now, we will create the network first and attach the MySQL container at star
where MySQL stores its data. However, we never ran a `docker volume create` command. Docker recognizes we want where MySQL stores its data. However, we never ran a `docker volume create` command. Docker recognizes we want
to use a named volume and creates one automatically for us. to use a named volume and creates one automatically for us.
!!! info "Troubleshooting"
If you see a `docker: no matching manifest` error, it's because you're trying to run the container in a different
architecture than amd64, which is the only supported architecture for the mysql image at the moment. To solve this
add the flag `--platform linux/amd64` in the previous command. So your new command should look like this:
```bash
docker run -d \
--network todo-app --network-alias mysql --platform linux/amd64 \
-v todo-mysql-data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=secret \
-e MYSQL_DATABASE=todos \
mysql:5.7
```
1. To confirm we have the database up and running, connect to the database and verify it connects. 1. To confirm we have the database up and running, connect to the database and verify it connects.
```bash ```bash
@@ -86,6 +111,8 @@ For now, we will create the network first and attach the MySQL container at star
Hooray! We have our `todos` database and it's ready for us to use! Hooray! We have our `todos` database and it's ready for us to use!
To exit the sql terminal type `exit` in the terminal.
## Connecting to MySQL ## Connecting to MySQL
@@ -156,7 +183,7 @@ The todo app supports the setting of a few environment variables to specify MySQ
A more secure mechanism is to use the secret support provided by your container orchestration framework. In most cases, A more secure mechanism is to use the secret support provided by your container orchestration framework. In most cases,
these secrets are mounted as files in the running container. You'll see many apps (including the MySQL image and the todo app) these secrets are mounted as files in the running container. You'll see many apps (including the MySQL image and the todo app)
also support env vars with a `_FILE` suffix to point to a file containing the file. also support env vars with a `_FILE` suffix to point to a file containing the variable.
As an example, setting the `MYSQL_PASSWORD_FILE` var will cause the app to use the contents of the referenced file As an example, setting the `MYSQL_PASSWORD_FILE` var will cause the app to use the contents of the referenced file
as the connection password. Docker doesn't do anything to support these env vars. Your app will need to know to look for as the connection password. Docker doesn't do anything to support these env vars. Your app will need to know to look for
@@ -165,11 +192,11 @@ The todo app supports the setting of a few environment variables to specify MySQ
With all of that explained, let's start our dev-ready container! With all of that explained, let's start our dev-ready container!
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). 1. We'll specify each of the environment variables above, as well as connect the container to our app network.
```bash hl_lines="3 4 5 6 7" ```bash hl_lines="3 4 5 6 7"
docker run -dp 3000:3000 \ docker run -dp 3000:3000 \
-w /app -v ${PWD}:/app \ -w /app -v "$(pwd):/app" \
--network todo-app \ --network todo-app \
-e MYSQL_HOST=mysql \ -e MYSQL_HOST=mysql \
-e MYSQL_USER=root \ -e MYSQL_USER=root \
@@ -179,6 +206,34 @@ With all of that explained, let's start our dev-ready container!
sh -c "yarn install && yarn run dev" sh -c "yarn install && yarn run dev"
``` ```
If you updated your docker file in the Bind Mount section of the tutorial use the updated command:
```bash hl_lines="3 4 5 6 7"
docker run -dp 3000:3000 \
-w /app -v "$(pwd):/app" \
--network todo-app \
-e MYSQL_HOST=mysql \
-e MYSQL_USER=root \
-e MYSQL_PASSWORD=secret \
-e MYSQL_DB=todos \
node:12-alpine \
sh -c "apk --no-cache --virtual build-dependencies add python2 make g++ && yarn install && yarn run dev"
```
If you are using PowerShell then use this command.
```powershell hl_lines="3 4 5 6 7"
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
--network todo-app `
-e MYSQL_HOST=mysql `
-e MYSQL_USER=root `
-e MYSQL_PASSWORD=secret `
-e MYSQL_DB=todos `
node:12-alpine `
sh -c "yarn install && yarn run dev"
```
1. If we look at the logs for the container (`docker logs <container-id>`), we should see a message indicating it's 1. If we look at the logs for the container (`docker logs <container-id>`), we should see a message indicating it's
using the mysql database. using the mysql database.
@@ -199,7 +254,7 @@ With all of that explained, let's start our dev-ready container!
is **secret**. is **secret**.
```bash ```bash
docker exec -ti <mysql-container-id> mysql -p todos docker exec -it <mysql-container-id> mysql -p todos
``` ```
And in the mysql shell, run the following: And in the mysql shell, run the following:
@@ -216,10 +271,10 @@ With all of that explained, let's start our dev-ready container!
Obviously, your table will look different because it has your items. But, you should see them stored there! Obviously, your table will look different because it has your items. But, you should see them stored there!
If you take a quick look at the Docker extension, you'll see that we have two app containers running. But, there's If you take a quick look at the Docker Dashboard, you'll see that we have two app containers running. But, there's
no real indication that they are grouped together in a single app. We'll see how to make that better shortly! no real indication that they are grouped together in a single app. We'll see how to make that better shortly!
![Docker Dashboard showing two ungrouped app containers](vs-multi-container-app.png) ![Docker Dashboard showing two ungrouped app containers](dashboard-multi-container-app.png)
## Recap ## Recap

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

View File

@@ -38,6 +38,8 @@ see a few flaws in the Dockerfile below. But, don't worry! We'll go over them.
```dockerfile ```dockerfile
FROM node:12-alpine FROM node:12-alpine
# Adding build tools to make yarn install work on Apple silicon / arm64 machines
RUN apk add --no-cache python2 g++ make
WORKDIR /app WORKDIR /app
COPY . . COPY . .
RUN yarn install --production RUN yarn install --production
@@ -97,10 +99,10 @@ command (remember that from earlier?).
At this point, you should have a running todo list manager with a few items, all built by you! At this point, you should have a running todo list manager with a few items, all built by you!
Now, let's make a few changes and learn about managing our containers. Now, let's make a few changes and learn about managing our containers.
If you take a quick look at the VSCode extension, you should see your two containers running now If you take a quick look at the Docker Dashboard, you should see your two containers running now
(this tutorial and your freshly launched app container)! (this tutorial and your freshly launched app container)!
![Docker Dashboard with tutorial and app containers running](vs-two-containers.png) ![Docker Dashboard with tutorial and app containers running](dashboard-two-containers.png)
## Recap ## Recap

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

View File

@@ -54,7 +54,10 @@ What you'll see is that the files created in one container aren't available in a
And look! There's no `data.txt` file there! That's because it was written to the scratch space for And look! There's no `data.txt` file there! That's because it was written to the scratch space for
only the first container. only the first container.
1. Go ahead and remove the first container using the `docker rm -f` command. 1. Go ahead and remove the first container using the `docker rm -f <container-id>` command.
```bash
docker rm -f <container-id>
```
## Container Volumes ## Container Volumes
@@ -91,7 +94,7 @@ Every time you use the volume, Docker will make sure the correct data is provide
docker volume create todo-db docker volume create todo-db
``` ```
1. Stop the todo app container once again in the Dashboard (or with `docker rm -f <id>`), as it is still running without using the persistent volume. 1. Stop the todo app container once again in the Dashboard (or with `docker rm -f <container-id>`), as it is still running without using the persistent volume.
1. Start the todo app container, but add the `-v` flag to specify a volume mount. We will use the named volume and mount 1. Start the todo app container, but add the `-v` flag to specify a volume mount. We will use the named volume and mount
it to `/etc/todos`, which will capture all files created at the path. it to `/etc/todos`, which will capture all files created at the path.
@@ -105,7 +108,7 @@ Every time you use the volume, Docker will make sure the correct data is provide
![Items added to todo list](items-added.png){: style="width: 55%; " } ![Items added to todo list](items-added.png){: style="width: 55%; " }
{: .text-center } {: .text-center }
1. Remove the container for the todo app. Use the Dashboard or `docker ps` to get the ID and then `docker rm -f <id>` to remove it. 1. Remove the container for the todo app. Use the Dashboard or `docker ps` to get the ID and then `docker rm -f <container-id>` to remove it.
1. Start a new container using the same command from above. 1. Start a new container using the same command from above.

View File

@@ -58,7 +58,7 @@ an example command that you will need to run to push to this repo.
Now that our image has been built and pushed into a registry, let's try running our app on a brand Now that our image has been built and pushed into a registry, let's try running our app on a brand
new instance that has never seen this container image! To do this, we will use Play with Docker. new instance that has never seen this container image! To do this, we will use Play with Docker.
1. Open your browser to [Play with Docker](http://play-with-docker.com). 1. Open your browser to [Play with Docker](https://labs.play-with-docker.com/).
1. Log in with your Docker Hub account. 1. Log in with your Docker Hub account.

View File

@@ -74,16 +74,17 @@ ways that we can remove the old container. Feel free to choose the path that you
### Removing a container using the Docker Dashboard ### Removing a container using the Docker Dashboard
If you open the VSCode Extension, you can remove a container with two clicks! It's certainly If you open the Docker dashboard, you can remove a container with two clicks! It's certainly
much easier than having to look up the container ID and remove it. much easier than having to look up the container ID and remove it.
1. With the extension opened, navigate to the container and right click. 1. With the dashboard opened, hover over the app container and you'll see a collection of action
buttons appear on the right.
1. Click on the remove container option 1. Click on the trash can icon to delete the container.
1. Confirm the removal and you're done! 1. Confirm the removal and you're done!
![Docker Dashboard - removing a container](vs-removing-container.png) ![Docker Dashboard - removing a container](dashboard-removing-container.png)
### Starting our updated app container ### Starting our updated app container

Binary file not shown.

Before

Width:  |  Height:  |  Size: 153 KiB

View File

@@ -14,7 +14,7 @@ changes and then restart the application. There are equivalent tools in most oth
## Quick Volume Type Comparisons ## Quick Volume Type Comparisons
Bind mounts and named volumes are the two main types of volumes that come with the Docker engine. However, additional Bind mounts and named volumes are the two main types of volumes that come with the Docker engine. However, additional
volume drivers are available to support other uses cases ([SFTP](https://github.com/vieux/docker-volume-sshfs), [Ceph](https://ceph.com/geen-categorie/getting-started-with-the-docker-rbd-volume-plugin/), [NetApp](https://netappdvp.readthedocs.io/en/stable/), [S3](https://github.com/elementar/docker-s3-volume), and more). volume drivers are available to support other use cases ([SFTP](https://github.com/vieux/docker-volume-sshfs), [Ceph](https://ceph.com/geen-categorie/getting-started-with-the-docker-rbd-volume-plugin/), [NetApp](https://netappdvp.readthedocs.io/en/stable/), [S3](https://github.com/elementar/docker-s3-volume), and more).
| | Named Volumes | Bind Mounts | | | Named Volumes | Bind Mounts |
| - | ------------- | ----------- | | - | ------------- | ----------- |
@@ -36,18 +36,42 @@ So, let's do it!
1. Make sure you don't have any previous `getting-started` containers running. 1. Make sure you don't have any previous `getting-started` containers running.
1. Run the following command (replace the ` \ ` characters with `` ` `` in Windows PowerShell). We'll explain what's going on afterwards: 1. Also make sure you are in app source code directory, i.e. `/path/to/getting-started/app`. If you aren't, you can `cd` into it, .e.g:
```bash
cd /path/to/getting-started/app
```
1. Now that you are in the `getting-started/app` directory, run the following command. We'll explain what's going on afterwards:
```bash ```bash
docker run -dp 3000:3000 \ docker run -dp 3000:3000 \
-w /app -v ${PWD}:/app \ -w /app -v "$(pwd):/app" \
node:12-alpine \ node:12-alpine \
sh -c "yarn install && yarn run dev" sh -c "yarn install && yarn run dev"
``` ```
If you are using PowerShell then use this command.
```powershell
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
node:12-alpine `
sh -c "yarn install && yarn run dev"
```
If you are using an Apple Silicon Mac or another ARM64 device then use this command.
```bash
docker run -dp 3000:3000 \
-w /app -v "$(pwd):/app" \
node:12-alpine \
sh -c "apk add --no-cache python2 g++ make && yarn install && yarn run dev"
```
- `-dp 3000:3000` - same as before. Run in detached (background) mode and create a port mapping - `-dp 3000:3000` - same as before. Run in detached (background) mode and create a port mapping
- `-w /app` - sets the "working directory" or the current directory that the command will run from - `-w /app` - sets the container's present working directory where the command will run from
- `-v ${PWD}:/app` - bind mount the current directory from the host in the container into the `/app` directory - `-v "$(pwd):/app"` - bind mount (link) the host's present `getting-started/app` directory to the container's `/app` directory. Note: Docker requires absolute paths for binding mounts, so in this example we use `pwd` for printing the absolute path of the working directory, i.e. the `app` directory, instead of typing it manually
- `node:12-alpine` - the image to use. Note that this is the base image for our app from the Dockerfile - `node:12-alpine` - the image to use. Note that this is the base image for our app from the Dockerfile
- `sh -c "yarn install && yarn run dev"` - the command. We're starting a shell using `sh` (alpine doesn't have `bash`) and - `sh -c "yarn install && yarn run dev"` - the command. We're starting a shell using `sh` (alpine doesn't have `bash`) and
running `yarn install` to install _all_ dependencies and then running `yarn run dev`. If we look in the `package.json`, running `yarn install` to install _all_ dependencies and then running `yarn run dev`. If we look in the `package.json`,
@@ -69,7 +93,7 @@ So, let's do it!
When you're done watching the logs, exit out by hitting `Ctrl`+`C`. When you're done watching the logs, exit out by hitting `Ctrl`+`C`.
1. Now, let's make a change to the app. In the `src/static/js/app.js` file, let's change the "Add Item" button to simply say 1. Now, let's make a change to the app. In the `src/static/js/app.js` file, let's change the "Add Item" button to simply say
"Add". This change will be on line 109. "Add". This change will be on line 109 - remember to save the file.
```diff ```diff
- {submitting ? 'Adding...' : 'Add Item'} - {submitting ? 'Adding...' : 'Add Item'}

View File

@@ -33,13 +33,13 @@ docker-compose version
for the current schema versions and the compatibility matrix. for the current schema versions and the compatibility matrix.
```yaml ```yaml
version: "3.7" version: "3.8"
``` ```
1. Next, we'll define the list of services (or containers) we want to run as part of our application. 1. Next, we'll define the list of services (or containers) we want to run as part of our application.
```yaml hl_lines="3" ```yaml hl_lines="3"
version: "3.7" version: "3.8"
services: services:
``` ```
@@ -49,11 +49,11 @@ And now, we'll start migrating a service at a time into the compose file.
## Defining the App Service ## Defining the App Service
To remember, this was the command we were using to define our app container (replace the ` \ ` characters with `` ` `` in Windows PowerShell). To remember, this was the command we were using to define our app container.
```bash ```bash
docker run -dp 3000:3000 \ docker run -dp 3000:3000 \
-w /app -v ${PWD}:/app \ -w /app -v "$(pwd):/app" \
--network todo-app \ --network todo-app \
-e MYSQL_HOST=mysql \ -e MYSQL_HOST=mysql \
-e MYSQL_USER=root \ -e MYSQL_USER=root \
@@ -63,11 +63,25 @@ docker run -dp 3000:3000 \
sh -c "yarn install && yarn run dev" sh -c "yarn install && yarn run dev"
``` ```
If you are using PowerShell then use this command.
```powershell
docker run -dp 3000:3000 `
-w /app -v "$(pwd):/app" `
--network todo-app `
-e MYSQL_HOST=mysql `
-e MYSQL_USER=root `
-e MYSQL_PASSWORD=secret `
-e MYSQL_DB=todos `
node:12-alpine `
sh -c "yarn install && yarn run dev"
```
1. First, let's define the service entry and the image for the container. We can pick any name for the service. 1. First, let's define the service entry and the image for the container. We can pick any name for the service.
The name will automatically become a network alias, which will be useful when defining our MySQL service. The name will automatically become a network alias, which will be useful when defining our MySQL service.
```yaml hl_lines="4 5" ```yaml hl_lines="4 5"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -78,7 +92,7 @@ docker run -dp 3000:3000 \
So, let's go ahead and move that into our file. So, let's go ahead and move that into our file.
```yaml hl_lines="6" ```yaml hl_lines="6"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -88,11 +102,11 @@ docker run -dp 3000:3000 \
1. Let's migrate the `-p 3000:3000` part of the command by defining the `ports` for the service. We will use the 1. Let's migrate the `-p 3000:3000` part of the command by defining the `ports` for the service. We will use the
[short syntax](https://docs.docker.com/compose/compose-file/#short-syntax-1) here, but there is also a more verbose [short syntax](https://docs.docker.com/compose/compose-file/compose-file-v3/#short-syntax-1) here, but there is also a more verbose
[long syntax](https://docs.docker.com/compose/compose-file/#long-syntax-1) available as well. [long syntax](https://docs.docker.com/compose/compose-file/compose-file-v3/#long-syntax-1) available as well.
```yaml hl_lines="7 8" ```yaml hl_lines="7 8"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -102,13 +116,13 @@ docker run -dp 3000:3000 \
- 3000:3000 - 3000:3000
``` ```
1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v ${PWD}:/app`) by using 1. Next, we'll migrate both the working directory (`-w /app`) and the volume mapping (`-v "$(pwd):/app"`) by using
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. the `working_dir` and `volumes` definitions. Volumes also has a [short](https://docs.docker.com/compose/compose-file/compose-file-v3/#short-syntax-3) and [long](https://docs.docker.com/compose/compose-file/compose-file-v3/#long-syntax-3) syntax.
One advantage of Docker Compose volume definitions is we can use relative paths from the current directory. One advantage of Docker Compose volume definitions is we can use relative paths from the current directory.
```yaml hl_lines="9 10 11" ```yaml hl_lines="9 10 11"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -124,7 +138,7 @@ docker run -dp 3000:3000 \
1. Finally, we need to migrate the environment variable definitions using the `environment` key. 1. Finally, we need to migrate the environment variable definitions using the `environment` key.
```yaml hl_lines="12 13 14 15 16" ```yaml hl_lines="12 13 14 15 16"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -145,7 +159,7 @@ docker run -dp 3000:3000 \
### Defining the MySQL Service ### Defining the MySQL Service
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): Now, it's time to define the MySQL service. The command that we used for that container was the following:
```bash ```bash
docker run -d \ docker run -d \
@@ -156,11 +170,22 @@ docker run -d \
mysql:5.7 mysql:5.7
``` ```
If you are using PowerShell then use this command.
```powershell
docker run -d `
--network todo-app --network-alias mysql `
-v todo-mysql-data:/var/lib/mysql `
-e MYSQL_ROOT_PASSWORD=secret `
-e MYSQL_DATABASE=todos `
mysql:5.7
```
1. We will first define the new service and name it `mysql` so it automatically gets the network alias. We'll 1. We will first define the new service and name it `mysql` so it automatically gets the network alias. We'll
go ahead and specify the image to use as well. go ahead and specify the image to use as well.
```yaml hl_lines="6 7" ```yaml hl_lines="6 7"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -172,10 +197,10 @@ docker run -d \
1. Next, we'll define the volume mapping. When we ran the container with `docker run`, the named volume was created 1. Next, we'll define the volume mapping. When we ran the container with `docker run`, the named volume was created
automatically. However, that doesn't happen when running with Compose. We need to define the volume in the top-level automatically. However, that doesn't happen when running with Compose. We need to define the volume in the top-level
`volumes:` section and then specify the mountpoint in the service config. By simply providing only the volume name, `volumes:` section and then specify the mountpoint in the service config. By simply providing only the volume name,
the default options are used. There are [many more options available](https://docs.docker.com/compose/compose-file/#volume-configuration-reference) though. the default options are used. There are [many more options available](https://docs.docker.com/compose/compose-file/compose-file-v3/#volume-configuration-reference) though.
```yaml hl_lines="8 9 10 11 12" ```yaml hl_lines="8 9 10 11 12"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -192,7 +217,7 @@ docker run -d \
1. Finally, we only need to specify the environment variables. 1. Finally, we only need to specify the environment variables.
```yaml hl_lines="10 11 12" ```yaml hl_lines="10 11 12"
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -213,7 +238,7 @@ At this point, our complete `docker-compose.yml` should look like this:
```yaml ```yaml
version: "3.7" version: "3.8"
services: services:
app: app:
@@ -293,15 +318,19 @@ Now that we have our `docker-compose.yml` file, we can start it up!
1. At this point, you should be able to open your app and see it running. And hey! We're down to a single command! 1. At this point, you should be able to open your app and see it running. And hey! We're down to a single command!
## Seeing our App Stack in the Docker Extension ## Seeing our App Stack in Docker Dashboard
If we look at the Docker Extension, we can changing our grouping options using the 'cog' and 'group by'. In this instance we want to see containers sharing a network. If we look at the Docker Dashboard, we'll see that there is a group named **app**. This is the "project name" from Docker
Compose and used to group the containers together. By default, the project name is simply the name of the directory that the
`docker-compose.yml` was located in.
![VS Extension with network](vs-app-project-collapsed.png) ![Docker Dashboard with app project](dashboard-app-project-collapsed.png)
If you twirl down the network, you will see the two containers we defined in the compose file. If you twirl down the app, you will see the two containers we defined in the compose file. The names are also a little
more descriptive, as they follow the pattern of `<project-name>_<service-name>_<replica-number>`. So, it's very easy to
quickly see what container is our app and which container is the mysql database.
![VS Extension with app network expanded](vs-app-project-expanded.png) ![Docker Dashboard with app project expanded](dashboard-app-project-expanded.png)
## Tearing it All Down ## Tearing it All Down

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 KiB

View File

@@ -1,5 +1,5 @@
mkdocs==1.0.4 mkdocs==1.3.0
mkdocs-material==4.6.3 mkdocs-material==4.6.3
mkdocs-minify-plugin==0.2.3 mkdocs-minify-plugin==0.2.3
pygments==2.6.1 pygments==2.7.4
pymdown-extensions==7.0 pymdown-extensions==7.0