service:docker
Различия
Показаны различия между двумя версиями страницы.
Предыдущая версия справа и слеваПредыдущая версияСледующая версия | Предыдущая версия | ||
service:docker [10.06.2024 13:16] – [Загрузка всех образов из архивов] viacheslav | service:docker [05.02.2025 12:44] (текущий) – [Buildx / Buildkit] viacheslav | ||
---|---|---|---|
Строка 1: | Строка 1: | ||
====== Docker ====== | ====== Docker ====== | ||
+ | <WRAP right box 25%> | ||
+ | — What is the first clue to build the container? | ||
+ | — It must be bound in thews of invincible iron.\\ | ||
+ | — What is the second clue to build the container? | ||
+ | — Bejewel the chest with the hallowed heart of glittering stone.\\ | ||
+ | — What is the third clue to build the container? | ||
+ | — Gift it with the essence of dragon amber, born of earth and root.\\ | ||
+ | — What is the fourth clue to build the container? | ||
+ | — A sacrifice of clay. The power to bind its parts.\\ | ||
+ | — What is the fifth clue to build the container? | ||
+ | — Craft it from wood no mortal blade can carve. Find the wicked tree.\\ | ||
+ | — What is the sixth clue to build the container? | ||
+ | — The strength of love denied. The soul of a dead hero shall empower it.\\ | ||
+ | — What is the seventh clue to build the container? | ||
+ | — Temper it in the tears of the weeping moon.\\ | ||
+ | — What is the eighth clue to build the container? | ||
+ | — Forged by the legendary Black Gnarl, beneath his binding song.\\ | ||
+ | — Each of the hearts have I given.\\ | ||
+ | — And each of the riddles have I returned. I am free! Stay at your task, my fool. No greater curse might I impart! | ||
+ | |||
+ | //Anvil of Dawn// | ||
+ | </ | ||
===== Обновление ===== | ===== Обновление ===== | ||
Строка 12: | Строка 34: | ||
https:// | https:// | ||
+ | ==== Buildx / Buildkit ==== | ||
+ | Новый сборщик образов, | ||
+ | |||
+ | Установка | ||
+ | <code bash> | ||
+ | sudo apt install docker-buildx | ||
+ | </ | ||
+ | |||
+ | Сделать Buildkit сборщиком по умолчанию | ||
+ | <file json / | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | <code bash> | ||
+ | sudo systemctl restart docker.service | ||
+ | </ | ||
+ | |||
+ | Если Buildkit не установлен по умолчанию, | ||
+ | <code bash> | ||
+ | DOCKER_BUILDKIT=1 docker build -t my_image . | ||
+ | </ | ||
+ | https:// | ||
===== Чистка ===== | ===== Чистка ===== | ||
<file bash / | <file bash / | ||
Строка 532: | Строка 580: | ||
[[https:// | [[https:// | ||
+ | ==== nodejs ==== | ||
+ | Сборка в каталоге, | ||
+ | <code bash> | ||
+ | docker run --rm -w /home/node -v ./ | ||
+ | </ | ||
+ | |||
+ | Сложный и неэффективный вариант (пока не понял, что можно проще).\\ | ||
+ | Интересный приём - heredoc для '' | ||
+ | <code bash> | ||
+ | workdir=/ | ||
+ | imagename=front: | ||
+ | |||
+ | docker build -t $imagename -f - . << EOF | ||
+ | FROM node:16 | ||
+ | WORKDIR $workdir | ||
+ | COPY --chown=node: | ||
+ | USER node | ||
+ | # npm rebuild нужен для решения проблемы с правами cross-env: Permission denied | ||
+ | RUN npm rebuild && npm run build | ||
+ | EOF | ||
+ | |||
+ | # Вытащить каталоги client и admin из образа с архивацией gzip | ||
+ | id=$(docker create $imagename) | ||
+ | for i in client admin | ||
+ | do | ||
+ | docker cp $id: | ||
+ | done | ||
+ | docker rm $id | ||
+ | </ | ||
==== Скачивание и пересылка образа в закрытый контур ==== | ==== Скачивание и пересылка образа в закрытый контур ==== | ||
В закрытом контуре интернета нет, поэтому на какой-то внешней машине: | В закрытом контуре интернета нет, поэтому на какой-то внешней машине: | ||
Строка 550: | Строка 627: | ||
Выгрузка образов: | Выгрузка образов: | ||
- | На целевом сервере, объединение частей и загрузка образа | + | На целевом сервере: объединение частей и загрузка образа. |
<code bash> | <code bash> | ||
cat tomcat_jre11_* > tomcat_jre11.tar.gz | cat tomcat_jre11_* > tomcat_jre11.tar.gz | ||
Строка 597: | Строка 674: | ||
==== Убрать повторяющиеся куски кода из docker-compose.yml ==== | ==== Убрать повторяющиеся куски кода из docker-compose.yml ==== | ||
- | Называется " | + | Называется " |
+ | '' | ||
- | https:// | + | <code yaml> |
+ | version: ' | ||
+ | |||
+ | x-fluentd: & | ||
+ | driver: fluentd | ||
+ | options: & | ||
+ | fluentd-async-connect: | ||
+ | |||
+ | services: | ||
+ | nodeinfo: | ||
+ | image: nodeinfo | ||
+ | logging: | ||
+ | <<: *fluentd | ||
+ | options: | ||
+ | <<: *fluentdopts | ||
+ | tag: " | ||
+ | </ | ||
+ | |||
+ | https:// | ||
+ | https:// | ||
+ | |||
+ | ==== Сделать сеть с другим именем, | ||
+ | Все сервисы стандартно ссылаются на сеть default, а тут ей задано другое имя. В результате будет сеть elastic, но прописывать её в сервисы не надо. | ||
+ | <code yaml> | ||
+ | networks: | ||
+ | default: | ||
+ | name: elastic | ||
+ | external: false | ||
+ | </ | ||
+ | https:// |
service/docker.1718025406.txt.gz · Последнее изменение: 30.07.2024 19:20 (внешнее изменение)