{"id":481268,"date":"2026-05-27T13:19:20","date_gmt":"2026-05-27T13:19:20","guid":{"rendered":"https:\/\/savepearlharbor.com\/?p=481268"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=481268","title":{"rendered":"Healthchecks \u0432 Docker Compose \u0434\u043b\u044f Laravel: \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u043b\u0438\u0441\u044c \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435"},"content":{"rendered":"<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u044c \u0440\u0430\u0437 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0438 Laravel-\u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Docker Compose, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439\u00a0<code>SQLSTATE[08006]<\/code>\u00a0\u0438\u043b\u0438\u00a0<code>Connection refused<\/code>. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0448\u044c \u2014 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 \u043b\u043e\u043a\u0430\u043b\u043a\u0435 \u0442\u0435\u0440\u043f\u0438\u043c\u043e, \u043d\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u2014 \u044d\u0442\u043e \u0432 \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0434\u0435\u043f\u043b\u043e\u0438.<\/p>\n<p>\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Docker \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u00ab\u0436\u0438\u0432\u044b\u043c\u00bb, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0449\u0435\u043d. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435.<\/p>\n<p>\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435\u00a0<strong>healthcheck\u2019\u0438<\/strong>\u00a0\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u00a0<code>depends_on<\/code>\u00a0\u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c\u00a0<code>condition: service_healthy<\/code>. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 Laravel: PHP-FPM, PostgreSQL, Redis \u0438 Nginx.<\/p>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 depends_on \u0431\u0435\u0437 healthcheck \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442<\/h3>\n<p>\u041c\u043d\u043e\u0433\u0438\u0435 \u0434\u0443\u043c\u0430\u044e\u0442, \u0447\u0442\u043e\u00a0<code>depends_on: [db]<\/code>\u00a0\u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 Docker Compose \u0436\u0434\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b. \u041c\u0435\u0436\u0434\u0443 \u00ab\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f\u00bb \u0438 \u00ab\u0431\u0430\u0437\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b\u00bb \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 5\u201315 \u0441\u0435\u043a\u0443\u043d\u0434, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b Compose \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0436\u0434\u0430\u043b \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043d\u0443\u0436\u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u00a0<code>healthcheck<\/code>\u00a0\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u0411\u0414, Redis \u0438 \u0442. \u0434.).<\/p>\n<\/li>\n<li>\n<p>\u0412 \u0441\u0435\u0440\u0432\u0438\u0441\u0435-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c\u00a0<code>depends_on<\/code>\u00a0\u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0441\u00a0<code>condition: service_healthy<\/code>.<\/p>\n<\/li>\n<\/ol>\n<h3>Healthcheck \u0434\u043b\u044f PostgreSQL<\/h3>\n<p>\u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 Postgres \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u00a0<code>pg_isready<\/code>\u00a0\u2014 \u043e\u043d\u0430 \u0438 \u0435\u0441\u0442\u044c \u0441\u0430\u043c\u0430\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"yaml\">services:  db:    image: postgres:16-alpine    environment:      POSTGRES_DB: app      POSTGRES_USER: app      POSTGRES_PASSWORD: secret    volumes:      - pgdata:\/var\/lib\/postgresql\/data    healthcheck:      test: [\"CMD-SHELL\", \"pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}\"]      interval: 5s      timeout: 3s      retries: 10      start_period: 10s<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:87px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u00a0<code>start_period<\/code>. \u041e\u043d \u0437\u0430\u0434\u0430\u0451\u0442 \u00ab\u0433\u0440\u0435\u0439\u0441-\u043f\u0435\u0440\u0438\u043e\u0434\u00bb: \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u043b\u0430\u043c\u0438. \u0414\u043b\u044f Postgres \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f PGDATA, \u0438 pg_isready \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u00abnot accepting connections\u00bb.<\/p>\n<h3>Healthcheck \u0434\u043b\u044f Redis<\/h3>\n<pre><code class=\"yaml\">redis:    image: redis:7-alpine    healthcheck:      test: [\"CMD\", \"redis-cli\", \"ping\"]      interval: 5s      timeout: 3s      retries: 5      start_period: 5s<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00a0<code>redis-cli ping<\/code>\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u00a0<code>PONG<\/code>, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043e\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435\u00a0<code>-a $REDIS_PASSWORD<\/code>\u00a0\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0<code>REDISCLI_AUTH<\/code>, \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u0441\u0432\u0435\u0442\u0438\u043b\u0441\u044f \u0432\u00a0<code>docker ps<\/code>.<\/p>\n<h3>Healthcheck \u0434\u043b\u044f PHP-FPM<\/h3>\n<p>\u0421 PHP-FPM \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437\u00a0<code>php:8.3-fpm-alpine<\/code>\u00a0\u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0438 curl, \u043d\u0438 wget. \u0421\u0430\u043c\u044b\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 PHP-FPM \u0441\u0442\u0430\u0442\u0443\u0441-\u043f\u0438\u043d\u0433. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u0443\u043b\u0430:<\/p>\n<pre><code class=\"yaml\">  app:    build:      context: .      dockerfile: docker\/php\/Dockerfile    depends_on:      db:        condition: service_healthy      redis:        condition: service_healthy    healthcheck:      test: [\"CMD-SHELL\", \"SCRIPT_NAME=\/ping SCRIPT_FILENAME=\/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 | grep -q pong\"]      interval: 10s      timeout: 3s      retries: 5      start_period: 15s<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c fcgi \u0432 Dockerfile:<\/p>\n<pre><code class=\"bash\">RUN apk add --no-cache fcgi<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>Healthcheck \u0434\u043b\u044f Nginx<\/h3>\n<p>\u0414\u043b\u044f Nginx \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 wget (\u043e\u043d \u0435\u0441\u0442\u044c \u0432 alpine-\u043e\u0431\u0440\u0430\u0437\u0435):<\/p>\n<pre><code class=\"yaml\">  nginx:    image: nginx:alpine    depends_on:      app:        condition: service_healthy    healthcheck:      test: [\"CMD\", \"wget\", \"--quiet\", \"--tries=1\", \"--spider\", \"http:\/\/localhost\/health\"]      interval: 10s      timeout: 3s      retries: 3      start_period: 5s    ports:      - \"8080:80\"<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<p>\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 Nginx \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 location, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0438\u0434\u0451\u0442 \u0432 PHP:<\/p>\n<pre><code>location = \/health {    access_log off;    add_header Content-Type text\/plain;    return 200 \"ok\";}<\/code><div class=\"code-explainer\"><a href=\"https:\/\/sourcecraft.dev\/\" class=\"tm-button code-explainer__link\" style=\"visibility: hidden;\"><img style=\"width:14px;height:14px;object-fit:cover;object-position:left;\"\/><\/a><\/div><\/pre>\n<h3>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438<\/h3>\n<p><code>docker compose up --wait<\/code>\u00a0\u2014 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 healthy (\u0438\u043b\u0438 \u043d\u0435 \u0443\u043f\u0430\u0434\u0443\u0442). \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f CI.<\/p>\n<p><code>docker compose ps<\/code>\u00a0\u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 STATUS \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u043e\u0439\u00a0<em>(healthy)<\/em>\u00a0\u0438\u043b\u0438\u00a0<em>(unhealthy)<\/em>\u00a0\u2014 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.<\/p>\n<h3>\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/h3>\n<ul>\n<li>\n<p><strong>\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 interval<\/strong>\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443. 5\u201310 \u0441\u0435\u043a\u0443\u043d\u0434 \u2014 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.<\/p>\n<\/li>\n<li>\n<p><strong>retries \u00d7 interval<\/strong>\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0411\u0414 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0431\u044d\u043a\u0430\u043f\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0430 \u0432\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 retries: 3 \u0438 interval: 5s \u2014 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u0441\u044f \u043a\u0430\u043a unhealthy \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u0430\u0437\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0430\u0434\u0451\u0442.<\/p>\n<\/li>\n<li>\n<p><strong>Healthcheck \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c<\/strong>, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,\u00a0<code>pgrep postgres<\/code>\u00a0\u0432\u0435\u0440\u043d\u0451\u0442 \u0443\u0441\u043f\u0435\u0445 \u0435\u0449\u0451 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Postgres \u043f\u0440\u0438\u043c\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<li>\n<p><strong>\u041d\u0435 \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0439\u0442\u0435\u00a0<\/strong><code><strong>condition: service_healthy<\/strong><\/code><strong>\u00a0\u0432 \u043f\u0440\u043e\u0434\u0435 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0437\u043b\u0435<\/strong>: \u0435\u0441\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u043f\u0430\u0434\u0451\u0442 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f, \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u043d\u0435 \u00ab\u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.<\/p>\n<\/li>\n<\/ul>\n<h3>\u0418\u0442\u043e\u0433<\/h3>\n<p>\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a YAML \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0447\u0430\u0441\u044b \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0443\u0431\u0438\u0440\u0430\u044e\u0442 \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445\u00bb \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0430\u0434\u0430\u044e\u0442; \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435; \u0434\u0435\u043f\u043b\u043e\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0441\u0442\u043e\u0438\u0442 \u0433\u043e\u043b\u044b\u0439\u00a0<code>depends_on<\/code>\u00a0\u0431\u0435\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u2014 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c.<\/p>\n<p>\u0411\u043e\u043b\u044c\u0448\u0435 Healthcheck \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f docker compose \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 <a href=\"https:\/\/prog-time.ru\/spravochnik-healthcheck-docker-compose\/\" rel=\"noopener noreferrer nofollow\">\u0437\u0434\u0435\u0441\u044c<\/a>.<\/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\/1040132\/\">https:\/\/habr.com\/ru\/articles\/1040132\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u044c \u0440\u0430\u0437 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u043b\u0438 Laravel-\u043f\u0440\u043e\u0435\u043a\u0442 \u0432 Docker Compose, \u043d\u0430\u0432\u0435\u0440\u043d\u044f\u043a\u0430 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0438\u0441\u044c \u0441 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439: \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u0440\u0442\u0443\u0435\u0442 \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0441\u043f\u0435\u0432\u0430\u0435\u0442 \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u044f, \u0438 \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u043f\u0430\u0434\u0430\u044e\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439\u00a0SQLSTATE[08006]\u00a0\u0438\u043b\u0438\u00a0Connection refused. \u041f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0448\u044c \u2014 \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041d\u0430 \u043b\u043e\u043a\u0430\u043b\u043a\u0435 \u0442\u0435\u0440\u043f\u0438\u043c\u043e, \u043d\u043e \u0432 \u043f\u0440\u043e\u0434\u0430\u043a\u0448\u0435\u043d\u0435 \u2014 \u044d\u0442\u043e \u0432 \u043f\u0430\u0434\u0430\u044e\u0449\u0438\u0435 \u0434\u0435\u043f\u043b\u043e\u0438.\u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e Docker \u0441\u0447\u0438\u0442\u0430\u0435\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u00ab\u0436\u0438\u0432\u044b\u043c\u00bb, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0449\u0435\u043d. \u041d\u043e \u044d\u0442\u043e \u043d\u0435 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u0441\u0435\u0440\u0432\u0438\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u0433\u043e\u0442\u043e\u0432 \u043a \u0440\u0430\u0431\u043e\u0442\u0435.\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u2014 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435\u00a0healthcheck\u2019\u0438\u00a0\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u0435\u00a0depends_on\u00a0\u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u043c\u00a0condition: service_healthy. \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0440\u0430\u0437\u0431\u0435\u0440\u0451\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043b\u044f \u0442\u0438\u043f\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u0442\u0435\u043a\u0430 Laravel: PHP-FPM, PostgreSQL, Redis \u0438 Nginx.\u041f\u043e\u0447\u0435\u043c\u0443 depends_on \u0431\u0435\u0437 healthcheck \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442\u041c\u043d\u043e\u0433\u0438\u0435 \u0434\u0443\u043c\u0430\u044e\u0442, \u0447\u0442\u043e\u00a0depends_on: [db]\u00a0\u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u0441 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0436\u0434\u0430\u0442\u044c, \u043f\u043e\u043a\u0430 \u0431\u0430\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0442\u043e\u0432\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 Docker Compose \u0436\u0434\u0451\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u2014 \u0442\u043e \u0435\u0441\u0442\u044c \u043c\u043e\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0430\u043b. \u041c\u0435\u0436\u0434\u0443 \u00ab\u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u043b\u0441\u044f\u00bb \u0438 \u00ab\u0431\u0430\u0437\u0430 \u0433\u043e\u0442\u043e\u0432\u0430 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u044b\u00bb \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u043e\u0439\u0442\u0438 5\u201315 \u0441\u0435\u043a\u0443\u043d\u0434, \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u0439 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.\u0427\u0442\u043e\u0431\u044b Compose \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0436\u0434\u0430\u043b \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430, \u043d\u0443\u0436\u043d\u043e:\u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c\u00a0healthcheck\u00a0\u0443 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0432\u0438\u0441\u0430 (\u0411\u0414, Redis \u0438 \u0442. \u0434.).\u0412 \u0441\u0435\u0440\u0432\u0438\u0441\u0435-\u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c\u00a0depends_on\u00a0\u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u043e\u0439 \u0444\u043e\u0440\u043c\u0435 \u0441\u00a0condition: service_healthy.Healthcheck \u0434\u043b\u044f PostgreSQL\u0412 \u043e\u0444\u0438\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437 Postgres \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u00a0pg_isready\u00a0\u2014 \u043e\u043d\u0430 \u0438 \u0435\u0441\u0442\u044c \u0441\u0430\u043c\u0430\u044f \u043d\u0430\u0434\u0451\u0436\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u0438:services:  db:    image: postgres:16-alpine    environment:      POSTGRES_DB: app      POSTGRES_USER: app      POSTGRES_PASSWORD: secret    volumes:      &#8212; pgdata:\/var\/lib\/postgresql\/data    healthcheck:      test: [&#171;CMD-SHELL&#187;, &#171;pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}&#187;]      interval: 5s      timeout: 3s      retries: 10      start_period: 10s\u0412\u0430\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u2014 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u00a0start_period. \u041e\u043d \u0437\u0430\u0434\u0430\u0451\u0442 \u00ab\u0433\u0440\u0435\u0439\u0441-\u043f\u0435\u0440\u0438\u043e\u0434\u00bb: \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0435 \u044d\u0442\u043e\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0435\u0443\u0441\u043f\u0435\u0448\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u044e\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0430\u043b\u0430\u043c\u0438. \u0414\u043b\u044f Postgres \u044d\u0442\u043e \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u0435\u0440\u0432\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u0442\u0441\u044f PGDATA, \u0438 pg_isready \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u00abnot accepting connections\u00bb.Healthcheck \u0434\u043b\u044f Redisredis:    image: redis:7-alpine    healthcheck:      test: [&#171;CMD&#187;, &#171;redis-cli&#187;, &#171;ping&#187;]      interval: 5s      timeout: 3s      retries: 5      start_period: 5s\u041a\u043e\u043c\u0430\u043d\u0434\u0430\u00a0redis-cli ping\u00a0\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u00a0PONG, \u043a\u043e\u0433\u0434\u0430 \u0441\u0435\u0440\u0432\u0435\u0440 \u0433\u043e\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0430 \u0430\u0432\u0442\u043e\u0440\u0438\u0437\u0430\u0446\u0438\u044f, \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435\u00a0-a $REDIS_PASSWORD\u00a0\u0438\u043b\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0REDISCLI_AUTH, \u0447\u0442\u043e\u0431\u044b \u043f\u0430\u0440\u043e\u043b\u044c \u043d\u0435 \u0441\u0432\u0435\u0442\u0438\u043b\u0441\u044f \u0432\u00a0docker ps.Healthcheck \u0434\u043b\u044f PHP-FPM\u0421 PHP-FPM \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u0432 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043e\u0431\u0440\u0430\u0437\u00a0php:8.3-fpm-alpine\u00a0\u043d\u0435 \u0432\u0445\u043e\u0434\u0438\u0442 \u043d\u0438 curl, \u043d\u0438 wget. \u0421\u0430\u043c\u044b\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0430\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u2014 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0439 \u0432 PHP-FPM \u0441\u0442\u0430\u0442\u0443\u0441-\u043f\u0438\u043d\u0433. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 \u043f\u0443\u043b\u0430:  app:    build:      context: .      dockerfile: docker\/php\/Dockerfile    depends_on:      db:        condition: service_healthy      redis:        condition: service_healthy    healthcheck:      test: [&#171;CMD-SHELL&#187;, &#171;SCRIPT_NAME=\/ping SCRIPT_FILENAME=\/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 | grep -q pong&#187;]      interval: 10s      timeout: 3s      retries: 5      start_period: 15s\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c fcgi \u0432 Dockerfile:RUN apk add &#8212;no-cache fcgiHealthcheck \u0434\u043b\u044f Nginx\u0414\u043b\u044f Nginx \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0447\u0435\u0440\u0435\u0437 wget (\u043e\u043d \u0435\u0441\u0442\u044c \u0432 alpine-\u043e\u0431\u0440\u0430\u0437\u0435):  nginx:    image: nginx:alpine    depends_on:      app:        condition: service_healthy    healthcheck:      test: [&#171;CMD&#187;, &#171;wget&#187;, &#171;&#8212;quiet&#187;, &#171;&#8212;tries=1&#187;, &#171;&#8212;spider&#187;, &#171;http:\/\/localhost\/health&#187;]      interval: 10s      timeout: 3s      retries: 3      start_period: 5s    ports:      &#8212; &#171;8080:80&#8243;\u0412 \u043a\u043e\u043d\u0444\u0438\u0433\u0435 Nginx \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 location, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0438\u0434\u0451\u0442 \u0432 PHP:location = \/health {    access_log off;    add_header Content-Type text\/plain;    return 200 &#171;ok&#187;;}\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0444\u043b\u0430\u0433\u0438docker compose up &#8212;wait\u00a0\u2014 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442 \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043e\u043d\u0438 \u043d\u0435 \u0441\u0442\u0430\u043d\u0443\u0442 healthy (\u0438\u043b\u0438 \u043d\u0435 \u0443\u043f\u0430\u0434\u0443\u0442). \u0418\u0434\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442 \u0434\u043b\u044f CI.docker compose ps\u00a0\u043f\u043e\u043a\u0430\u0436\u0435\u0442 \u0441\u0442\u043e\u043b\u0431\u0435\u0446 STATUS \u0441 \u043f\u043e\u043c\u0435\u0442\u043a\u043e\u0439\u00a0(healthy)\u00a0\u0438\u043b\u0438\u00a0(unhealthy)\u00a0\u2014 \u0443\u0434\u043e\u0431\u043d\u043e \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0439 \u0434\u0438\u0430\u0433\u043d\u043e\u0441\u0442\u0438\u043a\u0438 \u043d\u0430 \u0441\u0435\u0440\u0432\u0435\u0440\u0435.\u041f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 interval\u00a0\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u043b\u0438\u0448\u043d\u044e\u044e \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0443. 5\u201310 \u0441\u0435\u043a\u0443\u043d\u0434 \u2014 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e.retries \u00d7 interval\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044f. \u0415\u0441\u043b\u0438 \u0411\u0414 \u0432\u043e\u0441\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0431\u044d\u043a\u0430\u043f\u0430 2 \u043c\u0438\u043d\u0443\u0442\u044b, \u0430 \u0432\u044b \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043b\u0438 retries: 3 \u0438 interval: 5s \u2014 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440 \u043f\u043e\u043c\u0435\u0442\u0438\u0442\u0441\u044f \u043a\u0430\u043a unhealthy \u0440\u0430\u043d\u044c\u0448\u0435, \u0447\u0435\u043c \u0431\u0430\u0437\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u0443\u043f\u0430\u0434\u0451\u0442.Healthcheck \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0433\u043e\u0442\u043e\u0432\u043d\u043e\u0441\u0442\u044c, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,\u00a0pgrep postgres\u00a0\u0432\u0435\u0440\u043d\u0451\u0442 \u0443\u0441\u043f\u0435\u0445 \u0435\u0449\u0451 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a Postgres \u043f\u0440\u0438\u043c\u0435\u0442 \u043f\u0435\u0440\u0432\u043e\u0435 \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435.\u041d\u0435 \u0437\u043b\u043e\u0443\u043f\u043e\u0442\u0440\u0435\u0431\u043b\u044f\u0439\u0442\u0435\u00a0condition: service_healthy\u00a0\u0432 \u043f\u0440\u043e\u0434\u0435 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u0443\u0437\u043b\u0435: \u0435\u0441\u043b\u0438 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u0443\u043f\u0430\u0434\u0451\u0442 \u0438 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0441\u044f, \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044c \u043d\u0435 \u00ab\u043f\u0435\u0440\u0435\u043f\u043e\u0434\u043f\u0438\u0448\u0435\u0442\u0441\u044f\u00bb \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438. \u042d\u0442\u0430 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u0438 \u0441\u0442\u0430\u0440\u0442\u0435.\u0418\u0442\u043e\u0433\u041d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u0442\u0440\u043e\u0447\u0435\u043a YAML \u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0447\u0430\u0441\u044b \u043e\u0442\u043b\u0430\u0434\u043a\u0438 \u0438 \u0443\u0431\u0438\u0440\u0430\u044e\u0442 \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u00ab\u043c\u0430\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0445\u00bb \u043f\u0440\u043e\u0431\u043b\u0435\u043c: \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043f\u0430\u0434\u0430\u044e\u0442; \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043a\u0440\u0430\u0441\u043d\u044b\u0435; \u0434\u0435\u043f\u043b\u043e\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u043d\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u044b\u0432\u0430\u044e\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u0441\u0442\u043e\u0438\u0442 \u0433\u043e\u043b\u044b\u0439\u00a0depends_on\u00a0\u0431\u0435\u0437 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u2014 \u0441\u0430\u043c\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u044d\u0442\u043e \u043f\u043e\u0447\u0438\u043d\u0438\u0442\u044c.\u0411\u043e\u043b\u044c\u0448\u0435 Healthcheck \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0434\u043b\u044f docker compose \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c.\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\/1040132\/<\/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-481268","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481268","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=481268"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/481268\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=481268"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=481268"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=481268"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}