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 22:05] adminjp [references] |
docpublic:systemes:docker_linux [2024/12/08 13:24] (current) adminjp [Run docker compose & file www site] |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| * https:// | * https:// | ||
| * https:// | * https:// | ||
| + | * https:// | ||
| + | * https:// | ||
| Line 208: | Line 210: | ||
| 1 / | 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 | ||
| + | |||
| + | |||