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 14:25] adminjp [references] |
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 19: | Line 21: | ||
| https:// | https:// | ||
| + | ===== docker terminal /shell ===== | ||
| + | ==== list & get images ==== | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | REPOSITORY | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | |||
| + | C: | ||
| + | 1.27.2: Pulling from library/ | ||
| + | 2d429b9e73a6: | ||
| + | 9b1039c85176: | ||
| + | 9ad567d3b8a2: | ||
| + | 773c63cd62e4: | ||
| + | 1d2712910bdf: | ||
| + | 4b0adc47c460: | ||
| + | 171eebbdf235: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for nginx: | ||
| + | docker.io/ | ||
| + | |||
| + | C: | ||
| + | REPOSITORY | ||
| + | nginx 1.27.2 | ||
| + | </ | ||
| + | |||
| + | ==== run images ==== | ||
| + | |||
| + | running an image creates a instance of the image = container | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | 10-listen-on-ipv6-by-default.sh: | ||
| + | 10-listen-on-ipv6-by-default.sh: | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: using the " | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: nginx/ | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: getrlimit(RLIMIT_NOFILE): | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker processes | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 29 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 30 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 31 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 32 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 33 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 34 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 35 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 36 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 37 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 38 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 39 | ||
| + | 2024/11/12 14:38:28 [notice] 1#1: start worker process 40 | ||
| + | |||
| + | dans un autre terminal | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 3c24edd9cc6d | ||
| + | </ | ||
| + | |||
| + | === run ct as daemon === | ||
| + | | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | 8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831 | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 8aa18cfb6e51 | ||
| + | </ | ||
| + | |||
| + | === get log in daemon mode === | ||
| + | |||
| + | docker logs ct-ID | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | 10-listen-on-ipv6-by-default.sh: | ||
| + | 10-listen-on-ipv6-by-default.sh: | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: using the " | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: nginx/ | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14) | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: OS: Linux 5.15.153.1-microsoft-standard-WSL2 | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: getrlimit(RLIMIT_NOFILE): | ||
| + | 2024/11/12 14:42:30 [notice] 1#1: start worker processes | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== Network, expose port ==== | ||
| + | |||
| + | by default the 80 port is only exposed inside the CT, we have to export/ | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | 8aa18cfb6e51369a9d08463e24580c1eef308ed1f3f04bce324cb47760d1c831 | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | |||
| + | C: | ||
| + | 70a30ce86f2fd3d8556e731487b9d0505dd9e54bc1de6ee7040889b0ca785447 | ||
| + | </ | ||
| + | |||
| + | http:// | ||
| + | |||
| + | ==== list previous instances ==== | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 70a30ce86f2f | ||
| + | 8aa18cfb6e51 | ||
| + | 3c24edd9cc6d | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 70a30ce86f2f | ||
| + | |||
| + | C: | ||
| + | 70a30ce86f2f | ||
| + | |||
| + | C: | ||
| + | C: | ||
| + | CONTAINER ID | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 70a30ce86f2f | ||
| + | 8aa18cfb6e51 | ||
| + | 3c24edd9cc6d | ||
| + | </ | ||
| + | |||
| + | it is more convenient to name CT instead of using random IDs, option //--name// | ||
| + | |||
| + | < | ||
| + | C: | ||
| + | fb93da95c41f639d38a08d06e39ff14da2144e1f3baa1a33d9fa7099a1c0c4cd | ||
| + | |||
| + | C: | ||
| + | CONTAINER ID | ||
| + | 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 | ||
| + | </ | ||