{"id":283957,"date":"2017-03-27T13:15:02","date_gmt":"2017-03-27T09:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283957"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283957","title":{"rendered":"Docker \u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/48a\/1b8\/cec\/48a1b8cec90c446f907336dd62a58ca5.png\"\/>  <\/p>\n<p>\u041a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 docker-\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432?<br \/>  \u041a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f-\u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/habrahabr.ru\/company\/ruvds\/blog\/324756\/\" title=\"https:\/\/habrahabr.ru\/company\/ruvds\/blog\/324756\/\">Java \u0438 Docker: \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439<\/a> \u0438 \u0441\u043a\u0443\u0434\u043d\u044b\u0439 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0442\u0435\u043c\u0435. \u042f \u0434\u0430\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e LXC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 cgroup, \u0438 \u0442\u0430\u043c \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0430.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<p>Docker \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043b\u0438\u043c\u0438\u0442\u044b \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 cgroup, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u043f\u043e \u043f\u0443\u0442\u0438 (\u0432 Debian) <code>\/sys\/fs\/cgroup\/<\/code>, \u043d\u043e \u0434\u0430\u043b\u0435\u043a\u043e \u043d\u0435 \u0432\u0441\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0443\u043c\u0435\u044e\u0442 \u0441 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b <code>top, free, ps<\/code> \u0438 \u0442\u043f. \u041f\u0440\u043e\u0435\u043a\u0442 <a href=\"https:\/\/linuxcontainers.org\/ru\/\" title=\"https:\/\/linuxcontainers.org\/ru\/\">Linux Containers<\/a> \u043e\u0431\u043e\u0448\u043b\u0438 \u044d\u0442\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"https:\/\/linuxcontainers.org\/ru\/lxcfs\/introduction\/\" title=\"https:\/\/linuxcontainers.org\/ru\/lxcfs\/introduction\/\">LXCFS<\/a>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0444\u0430\u0439\u043b\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\/proc\/cpuinfo<br \/>  \u0441\u043f\u0438\u0441\u043e\u043a CPU<\/li>\n<li>\/proc\/diskstats<br \/>  \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 I\/O \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0435<\/li>\n<li>\/proc\/meminfo<br \/>  \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e<\/li>\n<li>\/proc\/stat<br \/>  \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u043c CPU<\/li>\n<li>\/proc\/swaps<br \/>  \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043a\u0430 \u043f\u043e swap<\/li>\n<li>\/proc\/uptime<br \/>  uptime \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430.<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0434\u043b\u044f <b>LXC 2.x<\/b> \u0432\u0441\u0451 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438\u0437 \u043a\u043e\u0440\u043e\u0431\u043a\u0438, \u0442\u043e <b>docker<\/b> \u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c.<br \/>  \u041f\u043e\u0434\u043e\u043f\u044b\u0442\u043d\u044b\u043c \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">Debian jessie 4.6.0-0.bpo.1-amd64 docker Server Version: 1.12.2 lxcfs: 2.0.6-1~bpo8+1<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u044f\u0434\u0440\u0443 Debian-\u0430 \u043d\u0443\u0436\u043d\u043e \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 cgroup, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">cgroup_enable=memory swapaccount=1<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c <code>lxcfs<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u043b\u0443\u0436\u0431\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># systemctl status lxcfs.service \u25cf lxcfs.service - FUSE filesystem for LXC<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e \u043f\u0443\u0442\u0438 <code>\/var\/lib\/lxcfs\/<\/code> \u043f\u043e\u044f\u0432\u044f\u0442\u0441\u044f \u0436\u0435\u043b\u0430\u0435\u043c\u044b\u0435 proc-\u0444\u0430\u0439\u043b\u044b.<br \/>  \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0438\u0445 \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u044c docker-\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043f\u043e\u0448\u0442\u0443\u0447\u043d\u043e. \u0412 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 docker-compose \u0444\u0430\u0439\u043b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">CT_name:   container_name: CT_name   hostname: CT_name   image: debian:stable   mem_limit: 512m   volumes:    - \/var\/lib\/lxcfs\/proc\/meminfo:\/proc\/meminfo    - \/var\/lib\/lxcfs\/proc\/uptime:\/proc\/uptime    - \/var\/lib\/lxcfs\/proc\/swaps:\/proc\/swaps    - \/var\/lib\/lxcfs\/proc\/cpuinfo:\/proc\/cpuinfo    - \/var\/lib\/lxcfs\/proc\/stat:\/proc\/stat    - \/var\/lib\/lxcfs\/proc\/diskstats:\/proc\/diskstats<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\"># docker exec CT_name cat \/proc\/uptime 247.0 247.0 # docker exec CT_name free -m              total       used       free     shared    buffers     cached Mem:           512         11        500       4322          0          0 -\/+ buffers\/cache:         11        500 Swap:          512          0        512<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0434\u0451\u043c \u0442\u0435\u0441\u0442, \u0443\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u043c\u044b\u0439 \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 &quot;Java \u0438 Docker: \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439&quot; \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"bash\">CT_name:   container_name: CT_name   hostname: CT_name   image: rafabene\/java-container:openjdk   mem_limit: 150m   volumes:    - \/var\/lib\/lxcfs\/proc\/meminfo:\/proc\/meminfo<\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"bash\">curl http:\/\/172.17.0.33:8080\/api\/memory Allocated more than 80% (73.5 MiB) of the Max allowed JVM memory size (73.5 MiB)<\/code><\/pre>\n<p>  <\/p>\n<p>\u0433\u0434\u0435 <code>172.17.0.33<\/code> \u2014 \u0432\u044b\u0434\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 ip.<br \/>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u043c, \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u043b\u043e \u0432\u044b\u0434\u0430\u043d\u043d\u044b\u0439 \u043b\u0438\u043c\u0438\u0442 \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435.<\/p>\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:\/\/habrahabr.ru\/post\/324918\/\"> https:\/\/habrahabr.ru\/post\/324918\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/48a\/1b8\/cec\/48a1b8cec90c446f907336dd62a58ca5.png\"\/>  <\/p>\n<p>\u041a\u0430\u043a \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443 docker-\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443 \u043d\u0435\u0433\u043e \u0435\u0441\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432?<br \/>  \u041a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0437\u0430\u043c\u0435\u0442\u043a\u0438 \u043c\u0435\u043d\u044f \u043f\u043e\u0434\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0430 \u0441\u0442\u0430\u0442\u044c\u044f-\u043f\u0435\u0440\u0435\u0432\u043e\u0434 <a href=\"https:\/\/habrahabr.ru\/company\/ruvds\/blog\/324756\/\" title=\"https:\/\/habrahabr.ru\/company\/ruvds\/blog\/324756\/\">Java \u0438 Docker: \u044d\u0442\u043e \u0434\u043e\u043b\u0436\u0435\u043d \u0437\u043d\u0430\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439<\/a> \u0438 \u0441\u043a\u0443\u0434\u043d\u044b\u0439 \u043d\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u043e\u0438\u0441\u043a \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043f\u043e \u0442\u0435\u043c\u0435. \u042f \u0434\u0430\u0432\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e LXC, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0442\u043e\u0436\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 cgroup, \u0438 \u0442\u0430\u043c \u044d\u0442\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0443\u0436\u0435 \u0440\u0435\u0448\u0435\u043d\u0430.<\/p>\n<p>  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-283957","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283957","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=283957"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283957\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}