{"id":285,"date":"2019-07-22T08:36:31","date_gmt":"2019-07-22T06:36:31","guid":{"rendered":"http:\/\/blog.xoupix.fr\/?p=285"},"modified":"2019-07-22T08:37:14","modified_gmt":"2019-07-22T06:37:14","slug":"simple-web-sharing-using-docker","status":"publish","type":"post","link":"https:\/\/blog.xoupix.fr\/index.php\/2019\/07\/22\/simple-web-sharing-using-docker\/","title":{"rendered":"Simple web sharing using docker"},"content":{"rendered":"\n<p>This week end, I needed to share a folder of my personal server to my family. There is a really simple way to do this using docker ! Let&#8217;s see it !<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>I will use the docker capacity to associate physical volumes to a specific container. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The -v flag<\/h2>\n\n\n\n<p>Checking the official Docker documentation, the &#8220;-v&#8221; flag &#8220;consists of three fields, separated by colon characters (<code>:<\/code>). The fields must be in the correct order, and the meaning of each field is not immediately obvious.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>In the case of named volumes, the first field is the name of the volume, and is unique on a given host machine. For anonymous volumes, the first field is omitted.<\/li><li>The second field is the path where the file or directory are mounted in the container.<\/li><li>The third field is optional, and is a comma-separated list of options, such as&nbsp;<code>ro<\/code>.&#8221;<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">The apache container<\/h2>\n\n\n\n<p>Docker allow to deploy a http server easily using the &#8220;httpd&#8221; container ( <a href=\"https:\/\/hub.docker.com\/_\/httpd\">https:\/\/hub.docker.com\/_\/httpd<\/a>). This container will run on my server, used to share my specific folder.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Pulling the image<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker pull httpd<\/pre>\n\n\n\n<p>This command will add the &#8220;httpd&#8221; image to my docker available images.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Running the container<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker run --detach --name=simple-share -v \/path\/to\/shared\/directory:\/usr\/local\/apache2\/htdocs\/my\/specific\/shared\/directory -p incoming-port:80 httpd:latest<\/pre>\n\n\n\n<p>This command will:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Run the container, naming it &#8220;simple-share&#8221;<\/li><li>Mount the &#8220;\/path\/to\/shared\/directory&#8221; to &#8220;\/usr\/local\/apache2\/htdocs\/my\/specific\/shared\/directory&#8221;<\/li><li>Redirect all requests on my server, using the &#8220;incoming-port&#8221;, to the http port<\/li><\/ul>\n\n\n\n<p>Using the http:\/\/<em>my-server-ip-or-dns<\/em>:<em>incoming-port<\/em>\/my\/specific\/shared\/directory, my family was able to access the shared content!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This week end, I needed to share a folder of my personal server to my family. There is a really simple way to do this using docker ! Let&#8217;s see it !<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-285","post","type-post","status-publish","format-standard","hentry","category-docker"],"_links":{"self":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/285","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/comments?post=285"}],"version-history":[{"count":3,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/285\/revisions"}],"predecessor-version":[{"id":288,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/posts\/285\/revisions\/288"}],"wp:attachment":[{"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/media?parent=285"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/categories?post=285"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.xoupix.fr\/index.php\/wp-json\/wp\/v2\/tags?post=285"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}