{"id":504218,"date":"2026-11-21T13:13:29","date_gmt":"2026-11-21T10:13:29","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=504218"},"modified":"2026-11-21T13:13:29","modified_gmt":"2026-11-21T10:13:29","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=504218","title":{"rendered":"docker compose &#8212;remove-orphans \u0443\u0434\u0430\u043b\u0438\u043b \u043c\u043d\u0435 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445: \u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0432 Compose"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><code>docker compose -f app.yml down --remove-orphans<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e <code>infra.yml<\/code>, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u0444\u0430\u0439\u043b\u0430 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u2014 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u0430\u043f\u043a\u0438, \u0430 \u043d\u0435 \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0442\u0430\u043a: \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (MongoDB, Redis, RabbitMQ, nginx, \u0442\u0443\u043d\u043d\u0435\u043b\u044c) \u0432 <code>infra.yml<\/code>, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u0432 <code>app.yml<\/code>, \u043e\u0431\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435. \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044f \u0431\u0430\u0437\u044b. \u0417\u0430\u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 <code>down --remove-orphans<\/code> \u2014 \u0438 \u043b\u0451\u0433 \u0432\u0435\u0441\u044c \u0441\u0442\u0435\u043a. \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u0446\u0435\u043b\u0435\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043b\u0435\u0436\u0430\u043b\u0438 \u0432 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043c\u0430\u0445. \u041d\u0438\u0436\u0435 \u2014 \u043a\u0430\u043a Compose \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u00ab\u0441\u0438\u0440\u043e\u0442\u00bb, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u0449\u0438\u0442\u044b.<\/p>\n<h2>\u041a\u0430\u043a Compose \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0418\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430, \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430:<\/p>\n<ol>\n<li>\n<p>\u0424\u043b\u0430\u0433 <code>-p<\/code> \/ <code>--project-name<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>COMPOSE_PROJECT_NAME<\/code> (\u0438\u0437 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0438\u0437 <code>.env<\/code> \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430).<\/p>\n<\/li>\n<li>\n<p>\u041a\u043b\u044e\u0447 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f <code>name:<\/code> \u0432 compose-\u0444\u0430\u0439\u043b\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u043f\u0430\u043f\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u0436\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0437 <code>-f<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0418\u043c\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0430\u043f\u043a\u0438, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d.<\/p>\n<\/li>\n<\/ol>\n<p>\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a. <code>infra.yml<\/code> \u0438 <code>app.yml<\/code> \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 <code>demo\/<\/code> \u0431\u0435\u0437 <code>name:<\/code> \u0438 <code>-p<\/code> \u0434\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 <code>demo<\/code>. \u0418\u043c\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443, \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0442\u0430\u043a \u0447\u0442\u043e <code>My.App<\/code> \u0438 <code>myapp<\/code> \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0441\u0442\u044c. \u0418\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 Compose: \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b <code>demo-redis-1<\/code>, \u0441\u0435\u0442\u044c <code>demo_default<\/code>, \u0442\u043e\u043c <code>demo_redis_data<\/code>.<\/p>\n<h2>\u041a\u0430\u043a Compose \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u00ab\u0441\u0438\u0440\u043e\u0442\u00bb<\/h2>\n<p>Compose \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445: \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u043d \u0437\u043d\u0430\u0435\u0442 \u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u043c\u0435\u0442\u043e\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u043a\u0438:<\/p>\n<p>\u2022 <code>com.docker.compose.project<\/code> \u2014 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430;<\/p>\n<p>\u2022 <code>com.docker.compose.service<\/code> \u2014 \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430;<\/p>\n<p>\u2022 <code>com.docker.compose.project.config_files<\/code> \u2014 \u0444\u0430\u0439\u043b\u044b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0433\u043e \u043f\u043e\u0434\u043d\u044f\u043b\u0438.<\/p>\n<p>\u041f\u0440\u0438 <code>up<\/code> \u0438 <code>down<\/code> Compose \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 Docker \u0432\u0441\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0441 <code>com.docker.compose.project=&lt;\u0438\u043c\u044f&gt;<\/code> \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 <code>-f<\/code>. \u0412\u0441\u0451, \u0447\u0435\u0433\u043e \u043d\u0435\u0442 \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u2014 \u0441\u0438\u0440\u043e\u0442\u0430. \u041c\u0435\u0442\u043a\u0443 <code>config_files<\/code> \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442: \u0442\u043e, \u0447\u0442\u043e redis \u043f\u043e\u0434\u043d\u044f\u0442 \u0438\u0437 <code>infra.yml<\/code>, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043d\u043e \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0411\u0435\u0437 <code>--remove-orphans<\/code> Compose \u0441\u0438\u0440\u043e\u0442 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0448\u0435\u0442 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 <code>Found orphan containers ([demo-redis-1]) for this project<\/code>. \u0421 \u0444\u043b\u0430\u0433\u043e\u043c \u2014 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 <code>up --remove-orphans<\/code> \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <code>COMPOSE_REMOVE_ORPHANS=true<\/code>, \u0430 <code>COMPOSE_IGNORE_ORPHANS=true<\/code> \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043b\u0443\u0448\u0438\u0442 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u044f\u0447\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435.<\/p>\n<h2>\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h2>\n<p>\u041f\u0430\u043f\u043a\u0430 <code>demo\/<\/code>, \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430. <code>infra.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">  redis:    image: redis:7-alpine    volumes:      - redis_data:\/datavolumes:  redis_data:<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper\"><\/span><\/a><\/div><\/pre>\n<p><code>app.yml<\/code>:<\/p>\n<pre><code class=\"yaml\">  web:    image: nginx:alpine    ports:      - \"8080:80\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u043e\u0431\u0430 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043a\u0438:<\/p>\n<pre><code>cd demodocker compose -f infra.yml up -ddocker compose -f app.yml up -ddocker ps --format \"table {{.Names}}\\t{{.Label \\\"com.docker.compose.project\\\"}}\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code>NAMES          PROJECTdemo-web-1     demodemo-redis-1   demo<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041e\u0431\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u2014 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 <code>demo<\/code>. \u0423\u0436\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 <code>up<\/code> \u043f\u0438\u0448\u0435\u0442 <code>Found orphan containers ([demo-redis-1])<\/code> \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0432\u043e\u043d\u043e\u0447\u0435\u043a, \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u00ab\u0447\u0438\u0441\u0442\u0438\u043c\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:<\/p>\n<pre><code>docker compose -f app.yml down --remove-orphansdocker ps<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>Redis \u043f\u0440\u043e\u043f\u0430\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 nginx. \u0414\u043b\u044f Compose \u0441\u0435\u0440\u0432\u0438\u0441\u0430 <code>redis<\/code> \u043d\u0435\u0442 \u0432 <code>app.yml<\/code>, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043d \u0441\u0438\u0440\u043e\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 <code>demo<\/code>. \u041f\u0440\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0439 <code>infra.yml<\/code> \u043e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0437\u043d\u0430\u0442\u044c.<\/p>\n<pre><code>docker volume ls<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code>DRIVER    VOLUME NAMElocal     demo_redis_data<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0422\u043e\u043c \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 <code>docker compose -f infra.yml up -d<\/code>: \u0438\u043c\u044f \u0442\u043e\u043c\u0430 \u0442\u043e \u0436\u0435, \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<h2>\u041f\u043e\u0447\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0436\u0438\u043b\u0438 \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u0436\u0438\u0432\u0443\u0442<\/h2>\n<p><code>down<\/code> \u0431\u0435\u0437 <code>-v<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0438, \u043d\u043e \u043d\u0435 \u0442\u043e\u043c\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043c\u0435\u043d\u044f \u0443\u0446\u0435\u043b\u0435\u043b\u0438 MongoDB, Redis \u0438 RabbitMQ. \u0420\u0438\u0441\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432 \u0442\u0440\u0451\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445: \u2022 <strong>\u041d\u0435\u0442 \u0442\u043e\u043c\u0430 \u0432\u043e\u043e\u0431\u0449\u0435.<\/strong> \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u043e\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u0431\u0435\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u2022 <strong>\u0410\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u043e\u043c.<\/strong> \u041e\u0431\u0440\u0430\u0437\u044b <code>mongo<\/code>, <code>redis<\/code>, <code>postgres<\/code> \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442 <code>VOLUME<\/code> \u0432 Dockerfile. \u0415\u0441\u043b\u0438 \u0432 compose-\u0444\u0430\u0439\u043b\u0435 \u0442\u043e\u043c \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d, \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0442\u043e\u043c\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c-\u0445\u0435\u0448\u0435\u043c. \u041f\u043e\u0441\u043b\u0435 <code>down<\/code> \u043e\u043d \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432\u0438\u0441\u0435\u0442\u044c \u0431\u0435\u0441\u0445\u043e\u0437\u043d\u044b\u043c, \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442, \u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 <code>docker volume prune<\/code> \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442. \u2022 <code>**down -v --remove-orphans**<\/code>. <code>-v<\/code> \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043c\u0430 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 <code>volumes:<\/code> \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0442\u043e\u043c\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0441 \u0447\u0443\u0436\u0438\u043c\u0438 \u00ab\u0441\u0438\u0440\u043e\u0442\u0430\u043c\u0438\u00bb \u2014 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0443\u0442\u044c \u043a \u043f\u043e\u0442\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p>\u041d\u0430\u0439\u0442\u0438 \u043e\u0441\u0438\u0440\u043e\u0442\u0435\u0432\u0448\u0438\u0439 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>docker volume ls -f dangling=truedocker volume inspect &lt;hash&gt; --format '{{.CreatedAt}} {{.Mountpoint}}'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u0443 \u043b\u044e\u0431\u043e\u0439 \u0431\u0430\u0437\u044b \u2014 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043c \u0438\u043b\u0438 bind mount, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u044f\u0432\u043d\u043e.<\/p>\n<h2>\u041a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c\u0441\u044f<\/h2>\n<p>\u0421\u0443\u0442\u044c \u043e\u0434\u043d\u0430: \u043b\u0438\u0431\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0434\u0438\u043d \u0438 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0434\u0443\u0442 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1 \u2014 name: \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430.<\/strong> \u0421\u0430\u043c\u044b\u0439 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439: \u0438\u043c\u044f \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442.<\/p>\n<pre><code class=\"yaml\"># infra.ymlname: myapp-infraservices:  ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code class=\"yaml\"># app.ymlname: myapp-appservices:  ...<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2 \u2014 <\/strong><code><strong>-p<\/strong><\/code><strong> \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435.<\/strong> \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043f\u043e\u043c\u043d\u044f\u0442 \u043f\u0440\u043e \u0444\u043b\u0430\u0433. \u0417\u0430\u0431\u044b\u043b\u0438 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 <code>demo<\/code> \u0441 \u0434\u0443\u0431\u043b\u044f\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u043c \u043f\u043e\u0440\u0442\u043e\u0432. \u041b\u0443\u0447\u0448\u0435 \u0437\u0430\u0448\u0438\u0442\u044c \u0432 Makefile \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442.<\/p>\n<pre><code>docker compose -p myapp-infra -f infra.yml up -ddocker compose -p myapp-app -f app.yml up -d<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><strong>\u0412\u0430\u0440\u0438\u0430\u043d\u0442 3 \u2014 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b.<\/strong> \u0422\u043e\u0433\u0434\u0430 <code>--remove-orphans<\/code> \u0441\u043d\u043e\u0432\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b.<\/p>\n<pre><code>docker compose -f infra.yml -f app.yml up -d --remove-orphans<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0438\u0445 \u0432 <code>.env<\/code>: <code>COMPOSE_FILE=infra.yml:app.yml<\/code> (\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c <code>:<\/code> \u043d\u0430 Linux\/macOS, <code>;<\/code> \u043d\u0430 Windows). \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 <code>compose.yml<\/code> \u0441 <code>include:<\/code> (Compose 2.20+). \u0410 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e: <code>docker compose up -d --no-deps web<\/code>.<\/p>\n<h2>\u041e\u0431\u0449\u0430\u044f \u0441\u0435\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432<\/h2>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f <code>web<\/code> \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c <code>redis<\/code> \u043f\u043e \u0438\u043c\u0435\u043d\u0438: \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0432\u043e\u044f \u0441\u0435\u0442\u044c <code>&lt;\u043f\u0440\u043e\u0435\u043a\u0442&gt;_default<\/code>. \u041d\u0443\u0436\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0441\u0435\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445:<\/p>\n<pre><code class=\"yaml\">networks:  default:    name: myapp-net    external: true<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code>docker network create myapp-net<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p><code>external: true<\/code> \u0437\u0430\u043e\u0434\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0441\u0435\u0442\u044c: <code>down<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0435\u0451 \u0443\u0434\u0430\u043b\u0438\u0442\u044c.<\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430<\/h2>\n<pre><code>docker compose ls<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<pre><code>NAME          STATUS      CONFIG FILESmyapp-app     running(1)  \/srv\/demo\/app.ymlmyapp-infra   running(1)  \/srv\/demo\/infra.yml<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 <code>CONFIG FILES<\/code> \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0432\u0438\u0434\u043d\u044b \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u2014 \u043e\u043d\u0438 \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 <code>--remove-orphans<\/code> \u043e\u043f\u0430\u0441\u0435\u043d.<\/p>\n<h2>\u041b\u043e\u0432\u0443\u0448\u043a\u0430 \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/h2>\n<p>\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c <code>name: myapp-infra<\/code> \u0432 \u0436\u0438\u0432\u043e\u0439 <code>infra.yml<\/code>, \u0431\u0430\u0437\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0443\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438. \u0422\u043e\u043c <code>redis_data<\/code> \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a <code>myapp-infra_redis_data<\/code>, Compose \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u043e\u0432\u044b\u0439, \u0430 \u0441\u0442\u0430\u0440\u044b\u0439 <code>demo_redis_data<\/code> \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u043c. \u0414\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u044b, \u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0445 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442. \u041f\u043b\u044e\u0441 \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b <code>demo-*<\/code> \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u044b. \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u2014 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u0442\u043e\u043c\u0430 \u044f\u0432\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:<\/p>\n<pre><code class=\"yaml\">name: myapp-infraservices:  redis:    image: redis:7-alpine    volumes:      - redis_data:\/datavolumes:  redis_data:    name: demo_redis_data   # \u0441\u0442\u0430\u0440\u043e\u0435 \u0438\u043c\u044f, \u0431\u0435\u0437 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430:<\/p>\n<pre><code># 1. \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0431\u0435\u0437 -vdocker compose -p demo -f infra.yml -f app.yml down# 2. \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044bdocker network create myapp-netdocker compose -f infra.yml up -ddocker compose -f app.yml up -d# 3. \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u043e\u043cdocker inspect myapp-infra-redis-1 --format '{{range .Mounts}}{{.Name}}{{end}}'<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><span class=\"sc-logo-wrapper icon-only\"><\/span><\/a><\/div><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0448\u0430\u0433\u0430 1 \u0441\u0442\u0430\u0440\u0430\u044f \u0441\u0435\u0442\u044c <code>demo_default<\/code> \u0443\u0434\u0430\u043b\u0438\u0442\u0441\u044f, \u0442\u043e\u043c\u0430 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f. \u0414\u043b\u044f \u0442\u043e\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 <code>down -v<\/code>, \u0435\u0441\u0442\u044c <code>external: true<\/code>: Compose \u0438\u0445 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442.<\/p>\n<h2>\u0427\u0435\u043a-\u043b\u0438\u0441\u0442<\/h2>\n<p>\u2022 \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e compose-\u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u0442\u044c <code>name:<\/code>.<\/p>\n<p>\u2022 \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u044b \u2014 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043c, \u0434\u043b\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u2014 \u0441 \u044f\u0432\u043d\u044b\u043c <code>name:<\/code> \u0438\u043b\u0438 <code>external: true<\/code>.<\/p>\n<p>\u2022 \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 <code>Found orphan containers<\/code> \u2014 \u043f\u043e\u0432\u043e\u0434 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>--remove-orphans<\/code>.<\/p>\n<p>\u2022 <code>COMPOSE_IGNORE_ORPHANS<\/code> \u0438 <code>COMPOSE_REMOVE_ORPHANS<\/code> \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e.<\/p>\n<p>\u2022 \u041f\u0435\u0440\u0435\u0434 \u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u2014 <code>docker compose ls<\/code>: \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442.<\/p>\n<p>\u2022 <code>down -v<\/code> \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>\u0410 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0433\u0440\u0430\u0431\u043b\u0438 Compose \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0432\u0430\u043c? \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.<\/p>\n<\/div>\n<p>\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/1110618\/\">https:\/\/habr.com\/ru\/articles\/1110618\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>docker compose -f app.yml down &#8212;remove-orphans \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438\u0437 \u0441\u043e\u0441\u0435\u0434\u043d\u0435\u0433\u043e infra.yml, \u0435\u0441\u043b\u0438 \u043e\u0431\u0430 \u0444\u0430\u0439\u043b\u0430 \u043b\u0435\u0436\u0430\u0442 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435. \u041f\u0440\u0438\u0447\u0438\u043d\u0430 \u2014 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430: \u043f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u044d\u0442\u043e \u0438\u043c\u044f \u043f\u0430\u043f\u043a\u0438, \u0430 \u043d\u0435 \u0444\u0430\u0439\u043b\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 \u0432 \u043e\u0434\u043d\u043e\u0439 \u0434\u0438\u0440\u0435\u043a\u0442\u043e\u0440\u0438\u0438 \u2014 \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442.\u0423 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u0442\u0430\u043a: \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 (MongoDB, Redis, RabbitMQ, nginx, \u0442\u0443\u043d\u043d\u0435\u043b\u044c) \u0432 infra.yml, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u0432 app.yml, \u043e\u0431\u0435 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435. \u0420\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0438, \u0447\u0442\u043e\u0431\u044b \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435, \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u044f \u0431\u0430\u0437\u044b. \u0417\u0430\u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 down &#8212;remove-orphans \u2014 \u0438 \u043b\u0451\u0433 \u0432\u0435\u0441\u044c \u0441\u0442\u0435\u043a. \u0414\u0430\u043d\u043d\u044b\u0435 \u0443\u0446\u0435\u043b\u0435\u043b\u0438 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043c\u0443, \u0447\u0442\u043e \u043b\u0435\u0436\u0430\u043b\u0438 \u0432 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0442\u043e\u043c\u0430\u0445. \u041d\u0438\u0436\u0435 \u2014 \u043a\u0430\u043a Compose \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u00ab\u0441\u0438\u0440\u043e\u0442\u00bb, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u044b \u0437\u0430\u0449\u0438\u0442\u044b.\u041a\u0430\u043a Compose \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0418\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0431\u0435\u0440\u0451\u0442\u0441\u044f \u0438\u0437 \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0441\u0440\u0430\u0431\u043e\u0442\u0430\u0432\u0448\u0435\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430, \u043f\u043e \u0443\u0431\u044b\u0432\u0430\u043d\u0438\u044e \u043f\u0440\u0438\u043e\u0440\u0438\u0442\u0435\u0442\u0430:\u0424\u043b\u0430\u0433 -p \/ &#8212;project-name.\u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f COMPOSE_PROJECT_NAME (\u0438\u0437 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u0438\u043b\u0438 \u0438\u0437 .env \u0432 \u043f\u0430\u043f\u043a\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430).\u041a\u043b\u044e\u0447 \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u0443\u0440\u043e\u0432\u043d\u044f name: \u0432 compose-\u0444\u0430\u0439\u043b\u0435.\u0418\u043c\u044f \u043f\u0430\u043f\u043a\u0438, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043b\u0435\u0436\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0438\u0437 -f.\u0418\u043c\u044f \u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u043f\u0430\u043f\u043a\u0438, \u0435\u0441\u043b\u0438 \u0444\u0430\u0439\u043b \u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d.\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u043d\u0438\u043a\u0430\u043a. infra.yml \u0438 app.yml \u0438\u0437 \u043f\u0430\u043f\u043a\u0438 demo\/ \u0431\u0435\u0437 name: \u0438 -p \u0434\u0430\u044e\u0442 \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 demo. \u0418\u043c\u044f \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043a \u043d\u0438\u0436\u043d\u0435\u043c\u0443 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0443, \u043b\u0438\u0448\u043d\u0438\u0435 \u0441\u0438\u043c\u0432\u043e\u043b\u044b \u0432\u044b\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f, \u0442\u0430\u043a \u0447\u0442\u043e My.App \u0438 myapp \u0442\u043e\u0436\u0435 \u043c\u043e\u0433\u0443\u0442 \u0441\u043e\u0432\u043f\u0430\u0441\u0442\u044c. \u0418\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u2014 \u044d\u0442\u043e \u043f\u0440\u0435\u0444\u0438\u043a\u0441 \u0434\u043b\u044f \u0432\u0441\u0435\u0433\u043e, \u0447\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0451\u0442 Compose: \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b demo-redis-1, \u0441\u0435\u0442\u044c demo_default, \u0442\u043e\u043c demo_redis_data.\u041a\u0430\u043a Compose \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u00ab\u0441\u0438\u0440\u043e\u0442\u00bbCompose \u043d\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0432 \u0444\u0430\u0439\u043b\u0430\u0445: \u0432\u0441\u0451, \u0447\u0442\u043e \u043e\u043d \u0437\u043d\u0430\u0435\u0442 \u043e \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 \u0438\u0437 \u043c\u0435\u0442\u043e\u043a \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041a\u0430\u0436\u0434\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u043c\u0435\u0442\u043a\u0438:\u2022 com.docker.compose.project \u2014 \u0438\u043c\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u0430;\u2022 com.docker.compose.service \u2014 \u0438\u043c\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430;\u2022 com.docker.compose.project.config_files \u2014 \u0444\u0430\u0439\u043b\u044b, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0433\u043e \u043f\u043e\u0434\u043d\u044f\u043b\u0438.\u041f\u0440\u0438 up \u0438 down Compose \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442 \u0443 Docker \u0432\u0441\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0441 com.docker.compose.project=&lt;\u0438\u043c\u044f&gt; \u0438 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0438\u0445 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0441\u043e \u0441\u043f\u0438\u0441\u043a\u043e\u043c \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438\u0437 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0445 -f. \u0412\u0441\u0451, \u0447\u0435\u0433\u043e \u043d\u0435\u0442 \u0432 \u044d\u0442\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445, \u2014 \u0441\u0438\u0440\u043e\u0442\u0430. \u041c\u0435\u0442\u043a\u0443 config_files \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442: \u0442\u043e, \u0447\u0442\u043e redis \u043f\u043e\u0434\u043d\u044f\u0442 \u0438\u0437 infra.yml, \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e, \u043d\u043e \u043d\u0435 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f. \u0411\u0435\u0437 &#8212;remove-orphans Compose \u0441\u0438\u0440\u043e\u0442 \u043d\u0435 \u0442\u0440\u043e\u0433\u0430\u0435\u0442, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0438\u0448\u0435\u0442 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 Found orphan containers ([demo-redis-1]) for this project. \u0421 \u0444\u043b\u0430\u0433\u043e\u043c \u2014 \u043e\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442. \u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u0435\u043b\u0430\u0435\u0442 up &#8212;remove-orphans \u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f COMPOSE_REMOVE_ORPHANS=true, \u0430 COMPOSE_IGNORE_ORPHANS=true \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043b\u0443\u0448\u0438\u0442 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0440\u044f\u0447\u0435\u0442 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0441\u0438\u0433\u043d\u0430\u043b \u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0435.\u0412\u043e\u0441\u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0434\u0435\u043d\u0438\u0435\u041f\u0430\u043f\u043a\u0430 demo\/, \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430. infra.yml:  redis:    image: redis:7-alpine    volumes:      &#8212; redis_data:\/datavolumes:  redis_data:app.yml:  web:    image: nginx:alpine    ports:      &#8212; &#171;8080:80&#8243;\u041f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u043c \u043e\u0431\u0430 \u0438 \u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043c\u0435\u0442\u043a\u0438:cd demodocker compose -f infra.yml up -ddocker compose -f app.yml up -ddocker ps &#8212;format &#171;table {{.Names}}\\t{{.Label \\&#187;com.docker.compose.project\\&#187;}}&#187;NAMES          PROJECTdemo-web-1     demodemo-redis-1   demo\u041e\u0431\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u2014 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 demo. \u0423\u0436\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 up \u043f\u0438\u0448\u0435\u0442 Found orphan containers ([demo-redis-1]) \u2014 \u044d\u0442\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u0437\u0432\u043e\u043d\u043e\u0447\u0435\u043a, \u0435\u0433\u043e \u043b\u0435\u0433\u043a\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c.\u0422\u0435\u043f\u0435\u0440\u044c \u00ab\u0447\u0438\u0441\u0442\u0438\u043c\u00bb \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435:docker compose -f app.yml down &#8212;remove-orphansdocker psRedis \u043f\u0440\u043e\u043f\u0430\u043b \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 nginx. \u0414\u043b\u044f Compose \u0441\u0435\u0440\u0432\u0438\u0441\u0430 redis \u043d\u0435\u0442 \u0432 app.yml, \u0437\u043d\u0430\u0447\u0438\u0442 \u043e\u043d \u0441\u0438\u0440\u043e\u0442\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 demo. \u041f\u0440\u043e \u0441\u043e\u0441\u0435\u0434\u043d\u0438\u0439 infra.yml \u043e\u043d \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u0438 \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d \u0437\u043d\u0430\u0442\u044c.docker volume lsDRIVER    VOLUME NAMElocal     demo_redis_data\u0422\u043e\u043c \u043d\u0430 \u043c\u0435\u0441\u0442\u0435. \u0412\u043e\u0441\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u2014 \u043e\u0431\u044b\u0447\u043d\u044b\u0439 docker compose -f infra.yml up -d: \u0438\u043c\u044f \u0442\u043e\u043c\u0430 \u0442\u043e \u0436\u0435, \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442 \u0441\u0442\u0430\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.\u041f\u043e\u0447\u0435\u043c\u0443 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432\u044b\u0436\u0438\u043b\u0438 \u0438 \u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0432\u044b\u0436\u0438\u0432\u0443\u0442down \u0431\u0435\u0437 -v \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0438 \u0441\u0435\u0442\u0438, \u043d\u043e \u043d\u0435 \u0442\u043e\u043c\u0430. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443 \u043c\u0435\u043d\u044f \u0443\u0446\u0435\u043b\u0435\u043b\u0438 MongoDB, Redis \u0438 RabbitMQ. \u0420\u0438\u0441\u043a \u0440\u0430\u0441\u0442\u0451\u0442 \u0432 \u0442\u0440\u0451\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445: \u2022 \u041d\u0435\u0442 \u0442\u043e\u043c\u0430 \u0432\u043e\u043e\u0431\u0449\u0435. \u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0441\u043b\u043e\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0430\u044e\u0442\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u043c, \u0431\u0435\u0437 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u0432. \u2022 \u0410\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u043e\u043c. \u041e\u0431\u0440\u0430\u0437\u044b mongo, redis, postgres \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u044e\u0442 VOLUME \u0432 Dockerfile. \u0415\u0441\u043b\u0438 \u0432 compose-\u0444\u0430\u0439\u043b\u0435 \u0442\u043e\u043c \u043d\u0435 \u043e\u043f\u0438\u0441\u0430\u043d, \u0434\u0430\u043d\u043d\u044b\u0435 \u043b\u0435\u0436\u0430\u0442 \u0432 \u0442\u043e\u043c\u0435 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c-\u0445\u0435\u0448\u0435\u043c. \u041f\u043e\u0441\u043b\u0435 down \u043e\u043d \u043e\u0441\u0442\u0430\u0451\u0442\u0441\u044f \u0432\u0438\u0441\u0435\u0442\u044c \u0431\u0435\u0441\u0445\u043e\u0437\u043d\u044b\u043c, \u043d\u043e\u0432\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u0434\u0445\u0432\u0430\u0442\u0438\u0442, \u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0436\u0435 docker volume prune \u0435\u0433\u043e \u0443\u0434\u0430\u043b\u0438\u0442. \u2022 **down -v &#8212;remove-orphans**. -v \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0442\u043e\u043c\u0430 \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 volumes: \u0438 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0435 \u0442\u043e\u043c\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432. \u041a\u043e\u043c\u0431\u0438\u043d\u0430\u0446\u0438\u044f \u0441 \u0447\u0443\u0436\u0438\u043c\u0438 \u00ab\u0441\u0438\u0440\u043e\u0442\u0430\u043c\u0438\u00bb \u2014 \u0441\u0430\u043c\u044b\u0439 \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 \u043f\u0443\u0442\u044c \u043a \u043f\u043e\u0442\u0435\u0440\u0435 \u0434\u0430\u043d\u043d\u044b\u0445.\u041d\u0430\u0439\u0442\u0438 \u043e\u0441\u0438\u0440\u043e\u0442\u0435\u0432\u0448\u0438\u0439 \u0430\u043d\u043e\u043d\u0438\u043c\u043d\u044b\u0439 \u0442\u043e\u043c \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a:docker volume ls -f dangling=truedocker volume inspect &lt;hash&gt; &#8212;format &#8216;{{.CreatedAt}} {{.Mountpoint}}&#8217;\u041f\u0440\u0430\u0432\u0438\u043b\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0435: \u0443 \u043b\u044e\u0431\u043e\u0439 \u0431\u0430\u0437\u044b \u2014 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043c \u0438\u043b\u0438 bind mount, \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u044f\u0432\u043d\u043e.\u041a\u0430\u043a \u0437\u0430\u0449\u0438\u0442\u0438\u0442\u044c\u0441\u044f\u0421\u0443\u0442\u044c \u043e\u0434\u043d\u0430: \u043b\u0438\u0431\u043e \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u043b\u0438\u0431\u043e \u043f\u0440\u043e\u0435\u043a\u0442 \u043e\u0434\u0438\u043d \u0438 \u0432 \u043a\u0430\u0436\u0434\u0443\u044e \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0438\u0434\u0443\u0442 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b.\u0412\u0430\u0440\u0438\u0430\u043d\u0442 1 \u2014 name: \u0432\u043d\u0443\u0442\u0440\u0438 \u0444\u0430\u0439\u043b\u0430. \u0421\u0430\u043c\u044b\u0439 \u043d\u0430\u0434\u0451\u0436\u043d\u044b\u0439: \u0438\u043c\u044f \u043f\u0443\u0442\u0435\u0448\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0444\u0430\u0439\u043b\u043e\u043c \u0438 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u0442\u043e \u0438 \u043e\u0442\u043a\u0443\u0434\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442.# infra.ymlname: myapp-infraservices:  &#8230;# app.ymlname: myapp-appservices:  &#8230;\u0412\u0430\u0440\u0438\u0430\u043d\u0442 2 \u2014 -p \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u0435. \u0420\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u043f\u043e\u043c\u043d\u044f\u0442 \u043f\u0440\u043e \u0444\u043b\u0430\u0433. \u0417\u0430\u0431\u044b\u043b\u0438 \u043e\u0434\u0438\u043d \u0440\u0430\u0437 \u2014 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0440\u0435\u0442\u0438\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 demo \u0441 \u0434\u0443\u0431\u043b\u044f\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0438 \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u043c \u043f\u043e\u0440\u0442\u043e\u0432. \u041b\u0443\u0447\u0448\u0435 \u0437\u0430\u0448\u0438\u0442\u044c \u0432 Makefile \u0438\u043b\u0438 \u0441\u043a\u0440\u0438\u043f\u0442.docker compose -p myapp-infra -f infra.yml up -ddocker compose -p myapp-app -f app.yml up -d\u0412\u0430\u0440\u0438\u0430\u043d\u0442 3 \u2014 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442, \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u0441\u0435 \u0444\u0430\u0439\u043b\u044b. \u0422\u043e\u0433\u0434\u0430 &#8212;remove-orphans \u0441\u043d\u043e\u0432\u0430 \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u0435\u043d \u0438 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u0434\u0430\u043b\u0451\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b.docker compose -f infra.yml -f app.yml up -d &#8212;remove-orphans\u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0435\u0440\u0435\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0444\u0430\u0439\u043b\u044b \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043f\u0440\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0438\u0445 \u0432 .env: COMPOSE_FILE=infra.yml:app.yml (\u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c : \u043d\u0430 Linux\/macOS, ; \u043d\u0430 Windows). \u0414\u0440\u0443\u0433\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u2014 \u0433\u043b\u0430\u0432\u043d\u044b\u0439 compose.yml \u0441 include: (Compose 2.20+). \u0410 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0430\u0434\u0440\u0435\u0441\u043d\u043e: docker compose up -d &#8212;no-deps web.\u041e\u0431\u0449\u0430\u044f \u0441\u0435\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432\u041f\u043e\u0441\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u044f web \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u043d\u0435\u0442 \u0432\u0438\u0434\u0435\u0442\u044c redis \u043f\u043e \u0438\u043c\u0435\u043d\u0438: \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0441\u0432\u043e\u044f \u0441\u0435\u0442\u044c &lt;\u043f\u0440\u043e\u0435\u043a\u0442&gt;_default. \u041d\u0443\u0436\u043d\u0430 \u043e\u0431\u0449\u0430\u044f \u0432\u043d\u0435\u0448\u043d\u044f\u044f \u0441\u0435\u0442\u044c \u0432 \u043e\u0431\u043e\u0438\u0445 \u0444\u0430\u0439\u043b\u0430\u0445:networks:  default:    name: myapp-net    external: truedocker network create myapp-netexternal: true \u0437\u0430\u043e\u0434\u043d\u043e \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0441\u0435\u0442\u044c: down \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0435\u0451 \u0443\u0434\u0430\u043b\u0438\u0442\u044c.\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430docker compose lsNAME          STATUS      CONFIG FILESmyapp-app     running(1)  \/srv\/demo\/app.ymlmyapp-infra   running(1)  \/srv\/demo\/infra.yml\u0415\u0441\u043b\u0438 \u0432 \u043a\u043e\u043b\u043e\u043d\u043a\u0435 CONFIG FILES \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0447\u0435\u0440\u0435\u0437 \u0437\u0430\u043f\u044f\u0442\u0443\u044e \u0432\u0438\u0434\u043d\u044b \u0444\u0430\u0439\u043b\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u2014 \u043e\u043d\u0438 \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442, \u0438 &#8212;remove-orphans \u043e\u043f\u0430\u0441\u0435\u043d.\u041b\u043e\u0432\u0443\u0448\u043a\u0430 \u043f\u0440\u0438 \u0441\u043c\u0435\u043d\u0435 \u0438\u043c\u0435\u043d\u0438 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0415\u0441\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u043e\u043f\u0438\u0441\u0430\u0442\u044c name: myapp-infra \u0432 \u0436\u0438\u0432\u043e\u0439 infra.yml, \u0431\u0430\u0437\u044b \u043f\u043e\u0434\u043d\u0438\u043c\u0443\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c\u0438. \u0422\u043e\u043c redis_data \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u043a myapp-infra_redis_data, Compose \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u043e\u0432\u044b\u0439, \u0430 \u0441\u0442\u0430\u0440\u044b\u0439 demo_redis_data \u043e\u0441\u0442\u0430\u043d\u0435\u0442\u0441\u044f \u043d\u0435\u0442\u0440\u043e\u043d\u0443\u0442\u044b\u043c. \u0414\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u043d\u044b, \u043d\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0438\u0445 \u043d\u0435 \u0432\u0438\u0434\u0438\u0442. \u041f\u043b\u044e\u0441 \u0441\u0442\u0430\u0440\u044b\u0435 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b demo-* \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0438 \u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u0440\u0442\u044b. \u0411\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0430\u044f \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u044f \u2014 \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u044f \u0442\u043e\u043c\u0430 \u044f\u0432\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u043d\u043e \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u043e \u043e\u0442 \u043f\u0440\u043e\u0435\u043a\u0442\u0430:name: myapp-infraservices:  redis:    image: redis:7-alpine    volumes:      &#8212; redis_data:\/datavolumes:  redis_data:    name: demo_redis_data   # \u0441\u0442\u0430\u0440\u043e\u0435 \u0438\u043c\u044f, \u0431\u0435\u0437 \u043f\u0440\u0435\u0444\u0438\u043a\u0441\u0430 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u041f\u043e\u0440\u044f\u0434\u043e\u043a \u043f\u0435\u0440\u0435\u0435\u0437\u0434\u0430:# 1. \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u0431\u0435\u0437 -vdocker compose -p demo -f infra.yml -f app.yml down# 2. \u043f\u043e\u0434\u043d\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044bdocker network create myapp-netdocker compose -f infra.yml up -ddocker compose -f app.yml up -d# 3. \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u0441\u043c\u043e\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d \u0441\u0442\u0430\u0440\u044b\u0439 \u0442\u043e\u043cdocker inspect myapp-infra-redis-1 &#8212;format &#8216;{{range .Mounts}}{{.Name}}{{end}}&#8217;\u041f\u043e\u0441\u043b\u0435 \u0448\u0430\u0433\u0430 1 \u0441\u0442\u0430\u0440\u0430\u044f \u0441\u0435\u0442\u044c demo_default \u0443\u0434\u0430\u043b\u0438\u0442\u0441\u044f, \u0442\u043e\u043c\u0430 \u043e\u0441\u0442\u0430\u043d\u0443\u0442\u0441\u044f. \u0414\u043b\u044f \u0442\u043e\u043c\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0435\u0440\u0435\u0436\u0438\u0442\u044c \u043b\u044e\u0431\u043e\u0439 down -v, \u0435\u0441\u0442\u044c external: true: Compose \u0438\u0445 \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0438 \u043d\u0435 \u0443\u0434\u0430\u043b\u044f\u0435\u0442.\u0427\u0435\u043a-\u043b\u0438\u0441\u0442\u2022 \u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e compose-\u0444\u0430\u0439\u043b\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e, \u0435\u0441\u0442\u044c name:.\u2022 \u0423 \u043a\u0430\u0436\u0434\u043e\u0439 \u0431\u0430\u0437\u044b \u2014 \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0442\u043e\u043c, \u0434\u043b\u044f \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u044b\u0445 \u2014 \u0441 \u044f\u0432\u043d\u044b\u043c name: \u0438\u043b\u0438 external: true.\u2022 \u041f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u0435 Found orphan containers \u2014 \u043f\u043e\u0432\u043e\u0434 \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a, \u0430 \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c &#8212;remove-orphans.\u2022 COMPOSE_IGNORE_ORPHANS \u0438 COMPOSE_REMOVE_ORPHANS \u043d\u0435 \u0441\u0442\u0430\u0432\u0438\u043c \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u043e.\u2022 \u041f\u0435\u0440\u0435\u0434 \u0447\u0438\u0441\u0442\u043a\u043e\u0439 \u2014 docker compose ls: \u0441\u0440\u0430\u0437\u0443 \u0432\u0438\u0434\u043d\u043e, \u043a\u0430\u043a\u0438\u0435 \u0444\u0430\u0439\u043b\u044b \u0434\u0435\u043b\u044f\u0442 \u043e\u0434\u0438\u043d \u043f\u0440\u043e\u0435\u043a\u0442.\u2022 down -v \u2014 \u0442\u043e\u043b\u044c\u043a\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u043d\u0435\u0441\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435.\u0410 \u043a\u0430\u043a\u0438\u0435 \u043d\u0435\u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0435 \u0433\u0440\u0430\u0431\u043b\u0438 Compose \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u0438\u0441\u044c \u0432\u0430\u043c? \u041f\u0438\u0448\u0438\u0442\u0435 \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 https:\/\/habr.com\/ru\/articles\/1110618\/<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-504218","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/504218","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=504218"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/504218\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=504218"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=504218"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=504218"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}