{"id":1668,"date":"2018-10-13T16:10:09","date_gmt":"2018-10-13T13:10:09","guid":{"rendered":"https:\/\/artem.services\/?p=50"},"modified":"2020-03-15T18:56:46","modified_gmt":"2020-03-15T15:56:46","slug":"1668","status":"publish","type":"post","link":"https:\/\/artem.services\/?p=1668&lang=en","title":{"rendered":"\u00a0Docker &#8212; API over TCP"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"size-full wp-image-27 aligncenter\" src=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo.png\" alt=\"\" width=\"1800\" height=\"531\" srcset=\"https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo.png 1800w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo-300x89.png 300w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo-768x227.png 768w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo-1024x302.png 1024w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo-954x281.png 954w, https:\/\/artem.services\/wp-content\/uploads\/2018\/10\/Docker-Logo-1354x399.png 1354w\" sizes=\"(max-width: 1800px) 100vw, 1800px\" \/><\/p>\n<p>All steps are relevant for distributions with <strong>systemd<\/strong> (tested on <strong>CentOS 7<\/strong> and<strong> Ubuntu 18.04<\/strong>)<\/p>\n<p>We look at the <strong>Docker<\/strong> launch command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ngrep &quot;ExecStart&quot; \/usr\/lib\/systemd\/system\/docker.service\r\n<\/pre>\n<blockquote><p><strong>Ubuntu 18.04<\/strong> has a different path, &quot;<strong>\/lib\/systemd\/system\/docker.service<\/strong>&quot;<\/p><\/blockquote>\n<p>&nbsp;<\/p>\n<p>We get something similar:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nExecStart=\/usr\/bin\/dockerd\r\n<\/pre>\n<p>Now create the &quot;<strong>override.conf<\/strong>&quot; file, just enter:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl edit docker\r\n<\/pre>\n<p>We insert the following there:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[Service]\r\nExecStart=\r\nExecStart=\/usr\/bin\/dockerd -H tcp:\/\/0.0.0.0:2375\r\n<\/pre>\n<p><!--more--><\/p>\n<p>For <strong>Ubuntu 18.04<\/strong>:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n[Service]\r\nExecStart=\r\nExecStart=\/usr\/bin\/dockerd -H tcp:\/\/0.0.0.0:2375 -H unix:\/\/\/var\/run\/docker.sock\r\n<\/pre>\n<p><strong>ExecStart<\/strong> should be two, the first with an empty value. In the previous step, we looked at the launch command, and added parameters for <strong>TCP<\/strong> to it.<\/p>\n<p>Reload the configuration of the daemon:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl daemon-reload\r\n<\/pre>\n<p>Restart <strong>Docker<\/strong> and see its status:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl restart docker\r\n<\/pre>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsystemctl status docker\r\n<\/pre>\n<p>If all is well, then you can still verify that <strong>Docker<\/strong> is listening on the port:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nnetstat -anp | grep &quot;:2375&quot;\r\n<\/pre>\n<p>Now you can remotely execute <strong>Docker<\/strong> commands, but you should consider that there is no authentication in this scheme.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>All steps are relevant for distributions with systemd (tested on CentOS 7 and Ubuntu 18.04) We look at the Docker launch command: Ubuntu 18.04 has a different path, &quot;\/lib\/systemd\/system\/docker.service&quot; &nbsp; We get something similar: Now create the &quot;override.conf&quot; file, just enter: We insert the following there:<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[399,975],"tags":[855,771,375],"_links":{"self":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1668"}],"collection":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1668"}],"version-history":[{"count":2,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1668\/revisions"}],"predecessor-version":[{"id":1671,"href":"https:\/\/artem.services\/index.php?rest_route=\/wp\/v2\/posts\/1668\/revisions\/1671"}],"wp:attachment":[{"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/artem.services\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}