This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
docpublic:systemes:docker_linux [2024/12/07 21:05] adminjp [install packages] |
docpublic:systemes:docker_linux [2024/12/08 13:24] (current) adminjp [Run docker compose & file www site] |
||
|---|---|---|---|
| Line 8: | Line 8: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| + | |||
| ==== install packages ==== | ==== install packages ==== | ||
| + | d' | ||
| < | < | ||
| root@debL74: | root@debL74: | ||
| </ | </ | ||
| + | |||
| + | ==== clean old docker ==== | ||
| retrait d' | retrait d' | ||
| Line 39: | Line 47: | ||
| </ | </ | ||
| - | install docker | + | ==== install docker |
| < | < | ||
| Line 76: | Line 84: | ||
| This message shows that your installation appears to be working correctly. | This message shows that your installation appears to be working correctly. | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ==== service ==== | ||
| + | |||
| + | < | ||
| + | root@debL74# | ||
| + | ● docker.service - Docker Application Container Engine | ||
| + | | ||
| + | | ||
| + | TriggeredBy: | ||
| + | Docs: https:// | ||
| + | Main PID: 939669 (dockerd) | ||
| + | Tasks: 14 | ||
| + | | ||
| + | CPU: 598ms | ||
| + | | ||
| + | | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | |||
| + | root@debL74# | ||
| + | ● containerd.service - containerd container runtime | ||
| + | | ||
| + | | ||
| + | Docs: https:// | ||
| + | Main PID: 939538 (containerd) | ||
| + | Tasks: 13 | ||
| + | | ||
| + | CPU: 1.955s | ||
| + | | ||
| + | | ||
| + | |||
| + | root@debL74# | ||
| + | Docker Compose version v2.29.7 | ||
| + | </ | ||
| + | ==== user group docker ==== | ||
| + | |||
| + | |||
| + | pour qu'une utilisateur non privilegier puisse lancer des CT docker il faut qu'il ai des privileges qu'il acquiere en appartenant au groupe docker, root le promote dans ce groupe | ||
| + | |||
| + | < | ||
| + | root@debL74# | ||
| + | </ | ||
| + | |||
| + | le user rafraichit son environement | ||
| + | |||
| + | < | ||
| + | jehan@debL74$ su - jehan | ||
| + | jehan@debL74$ id | ||
| + | uid=1005(jehan) gid=1005(jehan) groupes=1005(jehan), | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== commande de base user ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74$ docker ps | ||
| + | CONTAINER ID | ||
| + | jehan@debL74$ docker image ls | ||
| + | REPOSITORY | ||
| + | hello-world | ||
| + | jehan@debL74$ docker run hello-world | ||
| + | |||
| + | Hello from Docker! | ||
| + | </ | ||
| + | |||
| + | rechercher une distribution linux | ||
| + | |||
| + | < | ||
| + | jehan@debL74$ docker search almalinux | ||
| + | NAME DESCRIPTION | ||
| + | almalinux/ | ||
| + | almalinux | ||
| + | almalinux/ | ||
| + | almalinux/ | ||
| + | ... | ||
| + | < | ||
| + | |||
| + | |||
| + | recuperation de la distribution Linux | ||
| + | |||
| + | < | ||
| + | jehan@debL74-14212: | ||
| + | Using default tag: latest | ||
| + | latest: Pulling from library/ | ||
| + | de44b265507a: | ||
| + | Digest: sha256: | ||
| + | Status: Downloaded newer image for ubuntu: | ||
| + | docker.io/ | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== docker image store ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74$ docker image list | ||
| + | REPOSITORY | ||
| + | ubuntu | ||
| + | hello-world | ||
| + | jehan@debL74$ docker inspect --format=' | ||
| + | { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | ] | ||
| + | } | ||
| + | |||
| + | </ | ||
| + | |||
| + | === image file location === | ||
| + | |||
| + | < | ||
| + | jehan@debL74$ docker info | grep -i " | ||
| + | | ||
| + | jehan@debL74$ docker info | grep "Root Dir" | ||
| + | WARNING: bridge-nf-call-iptables is disabled | ||
| + | | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | root@debL74-14212: | ||
| + | 84 / | ||
| + | 1 / | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== run interactive terminal (-it) ==== | ||
| + | |||
| + | pour lancer notre image ubuntu et en instancier un container (CT) avec un shell interactif oouvert : | ||
| + | |||
| + | < | ||
| + | | ||
| + | root@c3b25bd7fa19:/# | ||
| + | PRETTY_NAME=" | ||
| + | NAME=" | ||
| + | VERSION_ID=" | ||
| + | VERSION=" | ||
| + | </ | ||
| + | |||
| + | |||
| + | ==== docker compose ==== | ||
| + | |||
| + | monter une image mysql + phpMyAdmin avec un compose file en yaml | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | services: | ||
| + | db: | ||
| + | image: mysql:8 | ||
| + | container_name: | ||
| + | restart: always | ||
| + | environment: | ||
| + | - MYSQL_USER=user | ||
| + | - MYSQL_PASSWORD=user-secret | ||
| + | - MYSQL_ROOT_PASSWORD=root-secret | ||
| + | volumes: | ||
| + | - ~/ | ||
| + | ports: | ||
| + | - 3306:3306 | ||
| + | |||
| + | phpmyadmin: | ||
| + | image: phpmyadmin | ||
| + | container_name: | ||
| + | restart: always | ||
| + | environment: | ||
| + | - PMA_HOST=db | ||
| + | - PMA_PORT=3306 | ||
| + | ports: | ||
| + | - 8081:80 | ||
| + | depends_on: | ||
| + | - db | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | jehan@debL74-14212: | ||
| + | [+] Running 31/2 | ||
| + | ✔ db Pulled | ||
| + | ✔ phpmyadmin Pulled | ||
| + | [+] Running 3/3 | ||
| + | ✔ Network docker_default | ||
| + | ✔ Container db Started | ||
| + | ✔ Container phpmyadmin | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | CONTAINER ID | ||
| + | 355a0c9fc396 | ||
| + | 0dc0c7d82738 | ||
| + | </ | ||
| + | |||
| + | service phpMyAdmin consultable sur http:// | ||
| + | |||
| + | ==== build a dockerfile ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | FROM php:apache | ||
| + | RUN docker-php-ext-install pdo pdo_mysql mysqli | ||
| + | </ | ||
| + | |||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | [+] Building 33.8s (6/6) FINISHED | ||
| + | => [internal] load build definition from dockerfile-phpjp1.dck | ||
| + | => => transferring dockerfile: 112B 0.0s | ||
| + | => [internal] load metadata for docker.io/ | ||
| + | => [internal] load .dockerignore | ||
| + | => => transferring context: 2B 0.0s | ||
| + | => [1/2] FROM docker.io/ | ||
| + | => => resolve docker.io/ | ||
| + | => => sha256: | ||
| + | ... | ||
| + | => => extracting sha256: | ||
| + | => [2/2] RUN docker-php-ext-install pdo pdo_mysql mysqli | ||
| + | => exporting to image 0.1s | ||
| + | => => exporting layers | ||
| + | => => writing image sha256: | ||
| + | </ | ||
| + | resultat, une image pas nomée " | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | REPOSITORY | ||
| + | < | ||
| + | ubuntu | ||
| + | mysql | ||
| + | phpmyadmin | ||
| + | hello-world | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | jehan@debL74-14212: | ||
| + | jehan@debL74-14212: | ||
| + | REPOSITORY | ||
| + | php-apache/ | ||
| + | </ | ||
| + | |||
| + | ===== docker compose et dockerfile combiné www-site ===== | ||
| + | |||
| + | ==== site DocumentRoot et content ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74-14212: | ||
| + | |||
| + | jehan@debL74: | ||
| + | < | ||
| + | </ | ||
| + | |||
| + | ==== DockerFile ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | FROM php:apache | ||
| + | RUN docker-php-ext-install pdo pdo_mysql mysqli | ||
| + | </ | ||
| + | |||
| + | ==== Docker compose projet www site ==== | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | services: | ||
| + | php: | ||
| + | build: | ||
| + | dockerfile: ./ | ||
| + | container_name: | ||
| + | restart: always | ||
| + | volumes: | ||
| + | - ~/ | ||
| + | ports: | ||
| + | - 9090:80 | ||
| + | </ | ||
| + | |||
| + | ==== Run docker compose & file www site ==== | ||
| + | |||
| + | instance de CT resultat de la combinaison du docker compose incluant le dockerfile ci-dessus | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | [+] Building 1.3s (7/7) FINISHED | ||
| + | => [php internal] load build definition from dockerfile-phpjp1.dck | ||
| + | => => transferring dockerfile: 112B 0.0s | ||
| + | => [php internal] load metadata for docker.io/ | ||
| + | => [php internal] load .dockerignore | ||
| + | => => transferring context: 2B 0.0s | ||
| + | => [php 1/2] FROM docker.io/ | ||
| + | => CACHED [php 2/2] RUN docker-php-ext-install pdo pdo_mysql mysqli | ||
| + | => [php] exporting to image 0.0s | ||
| + | => => exporting layers | ||
| + | => => writing image sha256: | ||
| + | => => naming to docker.io/ | ||
| + | => [php] resolving provenance for metadata file 0.0s | ||
| + | WARN[0001] Found orphan containers ([phpmyadmin db]) for this project. If you removed or renamed this service in your compose file, you can run this command with the --remove-orphans flag to clean it up. | ||
| + | [+] Running 1/1 | ||
| + | ✔ Container php Started | ||
| + | jehan@debL74: | ||
| + | CONTAINER ID | ||
| + | b22bc9482808 | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | jehan@debL74: | ||
| + | root@b22bc9482808:/ | ||
| + | index.html | ||
| + | </ | ||
| + | |||
| + | ==== consultation cliente ==== | ||
| + | |||
| + | http:// | ||
| + | |||
| + | docker web site JP1 | ||
| + | |||
| + | |||