This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
docpublic:systemes:docker_windows [2024/11/12 15:34] adminjp [own images] |
docpublic:systemes:docker_windows [2024/11/12 18:13] (current) adminjp [result] |
||
|---|---|---|---|
| Line 185: | Line 185: | ||
| ===== own images ===== | ===== own images ===== | ||
| + | |||
| + | ==== online sample code ==== | ||
| get a source code example on a nodeJS app from Nana | get a source code example on a nodeJS app from Nana | ||
| Line 198: | Line 200: | ||
| Receiving objects: 100% (52/52), 5.80 MiB | 3.42 MiB/s, done. | Receiving objects: 100% (52/52), 5.80 MiB | 3.42 MiB/s, done. | ||
| Resolving deltas: 100% (21/21), done. | Resolving deltas: 100% (21/21), done. | ||
| + | </ | ||
| + | |||
| + | from that sample code we creat an even simpler test code | ||
| + | |||
| + | ==== source files my-app ==== | ||
| + | |||
| + | server.js simple node-js app, with associated package.json dependencies file and the Dockerfile defining how to build the image | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | const express = require(' | ||
| + | const app = express(); | ||
| + | |||
| + | app.get('/', | ||
| + | res.send(" | ||
| + | }); | ||
| + | |||
| + | app.listen(3000, | ||
| + | console.log(" | ||
| + | }); | ||
| + | |||
| + | C: | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | } | ||
| + | |||
| + | C: | ||
| + | FROM node: | ||
| + | |||
| + | COPY package.json /app/ | ||
| + | COPY src /app/ | ||
| + | |||
| + | WORKDIR /app | ||
| + | |||
| + | RUN npm install | ||
| + | |||
| + | CMD [" | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== build image ==== | ||
| + | |||
| + | < | ||
| + | | ||
| + | |||
| + | 12/ | ||
| + | 12/ | ||
| + | 12/ | ||
| + | 12/ | ||
| + | 12/ | ||
| + | 2 fichier(s) | ||
| + | 3 Rép(s) | ||
| + | |||
| + | C: | ||
| + | [+] Building 27.2s (10/10) FINISHED | ||
| + | => [internal] load build definition from Dockerfile | ||
| + | => => transferring dockerfile: 164B 0.0s | ||
| + | => [internal] load metadata for docker.io/ | ||
| + | => [internal] load .dockerignore | ||
| + | => => transferring context: 2B 0.0s | ||
| + | => [1/5] FROM docker.io/ | ||
| + | => => resolve docker.io/ | ||
| + | => => sha256: | ||
| + | => => sha256: | ||
| + | => => sha256: | ||
| + | => => sha256: | ||
| + | => => sha256: | ||
| + | => => sha256: | ||
| + | => => extracting sha256: | ||
| + | => => sha256: | ||
| + | => => extracting sha256: | ||
| + | => => extracting sha256: | ||
| + | => => extracting sha256: | ||
| + | => [internal] load build context | ||
| + | => => transferring context: 242B 0.0s | ||
| + | => [2/5] COPY package.json /app/ 0.2s | ||
| + | => [3/5] COPY src /app/ 0.1s | ||
| + | => [4/5] WORKDIR /app 0.1s | ||
| + | => [5/5] RUN npm install | ||
| + | => exporting to image 0.3s | ||
| + | => => exporting layers | ||
| + | => => writing image sha256: | ||
| + | => => naming to docker.io/ | ||
| + | |||
| + | </ | ||
| + | |||
| + | ==== docker images my-node-app ==== | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | REPOSITORY | ||
| + | node-app-jp | ||
| + | nginx | ||
| + | </ | ||
| + | |||
| + | === run it === | ||
| + | |||
| + | < | ||
| + | |||
| + | C: | ||
| + | 8dd672b044ce7d872004220a9f2128f8b4a701b2165bee94c19aa59acb4f8c95 | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 8dd672b044ce | ||
| + | |||
| + | |||
| + | C: | ||
| + | app JP listening on port 3000! | ||
| + | </ | ||
| + | |||
| + | ==== result ==== | ||
| + | |||
| + | navigate to http:// | ||
| + | |||
| + | < | ||
| + | Welcome to JP App ! | ||
| + | </ | ||
| + | |||
| + | ===== docker compose ===== | ||
| + | |||
| + | manage multiple CT work together and in network | ||
| + | |||
| + | * Nana tuto https:// | ||
| + | |||
| + | |||
| + | |||
| + | ==== network ==== | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | d8f44158f792089020aeac910d3c79c15664b11e668f054948e73095a8cf886b | ||
| + | |||
| + | C: | ||
| + | NETWORK ID | ||
| + | 3d7e2cc5c6d6 | ||
| + | 067f0bdb2644 | ||
| + | d8f44158f792 | ||
| + | 86943d7c1114 | ||
| </ | </ | ||