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:03] adminjp [list previous instances] |
docpublic:systemes:docker_windows [2024/11/12 18:13] (current) adminjp [result] |
||
---|---|---|---|
Line 8: | Line 8: | ||
* prerequisit Win Service Linux (WSL2) : https:// | * prerequisit Win Service Linux (WSL2) : https:// | ||
* docker desktop for windows https:// | * docker desktop for windows https:// | ||
+ | * VScodium file-code editor https:// | ||
+ | * git https:// | ||
Line 180: | Line 182: | ||
CONTAINER ID | CONTAINER ID | ||
fb93da95c41f | fb93da95c41f | ||
+ | </ | ||
+ | |||
+ | ===== own images ===== | ||
+ | |||
+ | ==== online sample code ==== | ||
+ | |||
+ | get a source code example on a nodeJS app from Nana | ||
+ | |||
+ | < | ||
+ | jehan@G10JP24 MINGW64 ~/ | ||
+ | $ git clone https:// | ||
+ | Cloning into ' | ||
+ | remote: Enumerating objects: 52, done. | ||
+ | remote: Counting objects: 100% (21/21), done. | ||
+ | remote: Compressing objects: 100% (6/6), done. | ||
+ | remote: Total 52 (delta 16), reused 15 (delta 15), pack-reused 31 (from 1) | ||
+ | Receiving objects: 100% (52/52), 5.80 MiB | 3.42 MiB/s, 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 | ||
</ | </ |