<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="../assets/xml/rss.xsl" media="all"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title>SudoServers (Posts about vm)</title><link>https://sudoservers.com/</link><description></description><atom:link href="https://sudoservers.com/categories/vm.xml" rel="self" type="application/rss+xml"></atom:link><language>en</language><copyright>Contents © 2017 &lt;a href="mailto:willdeberry@gmail.com"&gt;Will DeBerry&lt;/a&gt; </copyright><lastBuildDate>Tue, 08 Aug 2017 00:48:36 GMT</lastBuildDate><generator>Nikola (getnikola.com)</generator><docs>http://blogs.law.harvard.edu/tech/rss</docs><item><title>Move all the things to Docker</title><link>https://sudoservers.com/posts/move-all-the-things-to-docker/</link><dc:creator>Will DeBerry</dc:creator><description>&lt;div&gt;&lt;p&gt;So what happens when you have a local esxi server and you realize that your resource usage is higher than what you are actually using....you blow it all away and migrate to docker! :)&lt;/p&gt;
&lt;p&gt;My setup consisted of 3 VMs total. A VM for a web server &lt;tt class="docutils literal"&gt;(nginx)&lt;/tt&gt;, a database VM which was both &lt;tt class="docutils literal"&gt;mysql&lt;/tt&gt; and &lt;tt class="docutils literal"&gt;mongodb&lt;/tt&gt;, and lastly, a DNS server (&lt;tt class="docutils literal"&gt;bind&lt;/tt&gt;) that also doubled as a &lt;tt class="docutils literal"&gt;salt&lt;/tt&gt; server. Obviously, the first thing done is back up all your files. In my case this involved nginx configurations, dns server configurations and a couple of databases I had running. I have also backed up my salt configurations but being that I am down sizing on the amount of servers to manage, not sure yet that salt actually fits or is even needed with the new setup.&lt;/p&gt;
&lt;p&gt;So outside of having to learn docker and docker-compose in general, there were 2 hurdles that really dragged this process out beyond a couple of hours to a couple of days. The first hurdle I ran into was getting letsencrpyt working properly. Because who wants to run a web server on http anymore, especially when a fully qualified cert is free and super easy to get. The second hurdle was getting nextcloud installed using their fpm image.&lt;/p&gt;
&lt;p&gt;The first hurdle was definitely the least worries of the two, but was definitely frustrating since I hit this wall 10 minutes into the transition. For letsencrpyt, I mainly used this &lt;a class="reference external" href="https://bitbucket.org/automationlogic/le-docker-compose.git"&gt;guide&lt;/a&gt;, and their source code to piece things together. The thing that killed me was copying and pasting was &lt;tt class="docutils literal"&gt;line 18&lt;/tt&gt; from their &lt;a class="reference external" href="https://bitbucket.org/automationlogic/le-docker-compose/src/2f1b37b842e3ed9aaa6aef645f7e0f6782308c1d/docker-compose.yml?at=master&amp;amp;fileviewer=file-view-default#docker-compose.yml-18"&gt;docker-compose.yml&lt;/a&gt; file. &lt;code&gt;--standalone-supported-challenges http-01&lt;/code&gt; is a depracated option to the certbot command now. So when I saw this, I ended up removing that argument alltogether rather than understanding what it was trying to accomplish. This led me down a 2 hour whole of trying to figure out why &lt;tt class="docutils literal"&gt;letsencrypt&lt;/tt&gt; was trying to use port 443 for generating a cert when 443 wasn't listening yet in the webserver, since I didn't have a cert. The answer, once I read the man pages, was to use &lt;code&gt;--preferred-challenges http&lt;/code&gt;. This forced things to be done over port 80 and generated the certs properly.&lt;/p&gt;
&lt;p&gt;Hurdle number two strictly involved with deploying nextcloud via docker using nginx as a frontend proxy. I used both upstream docker images provided by the nginx and nextcloud teams respectively. Nextcloud however, I decided to use their &lt;tt class="docutils literal"&gt;fpm&lt;/tt&gt; based image rather than their default. This was strictly decided because I felt like it would have been overkill to still a docker image with the apache webserver behind a webserver already being provided by &lt;tt class="docutils literal"&gt;nginx&lt;/tt&gt;.&lt;/p&gt;
&lt;p&gt;Anyways, nextcloud's docker image expects the volume for the nextcloud files to be mounted within the image at &lt;code&gt;/var/www/html&lt;/code&gt;. So I accomidated this and mounted a local nextcloud directory to where they wanted it.&lt;/p&gt;
&lt;pre class="code text"&gt;&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-1"&gt;&lt;/a&gt;nextcloud:
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-2"&gt;&lt;/a&gt;    image: nextcloud:fpm
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-3"&gt;&lt;/a&gt;    container_name: nextcloud
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-4"&gt;&lt;/a&gt;    ports:
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-5"&gt;&lt;/a&gt;        - '9000'
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-6"&gt;&lt;/a&gt;    links:
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-7"&gt;&lt;/a&gt;        - mysql
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-8"&gt;&lt;/a&gt;        - redis
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-9"&gt;&lt;/a&gt;    volumes:
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-10"&gt;&lt;/a&gt;        - ./www/html:/var/www/html
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-11"&gt;&lt;/a&gt;        - ../storage:/mnt
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-12"&gt;&lt;/a&gt;        - /etc/localtime:/etc/localtime:ro
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-13"&gt;&lt;/a&gt;    depends_on:
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-14"&gt;&lt;/a&gt;        - mysql
&lt;a name="rest_code_98e4bf6f7acb459b9683de0268c8d4b6-15"&gt;&lt;/a&gt;    restart: always
&lt;/pre&gt;&lt;p&gt;However, since I tend to have everything in the &lt;tt class="docutils literal"&gt;www&lt;/tt&gt; directory for &lt;tt class="docutils literal"&gt;nginx&lt;/tt&gt; organized per project, I mapped this to my &lt;tt class="docutils literal"&gt;nginx&lt;/tt&gt; docker image to &lt;code&gt;/var/www/nextcloud&lt;/code&gt;, as seen in my &lt;tt class="docutils literal"&gt;nginx&lt;/tt&gt; example below:&lt;/p&gt;
&lt;pre class="code text"&gt;&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-1"&gt;&lt;/a&gt;nginx:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-2"&gt;&lt;/a&gt;    build: ./nginx
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-3"&gt;&lt;/a&gt;    container_name: nginx
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-4"&gt;&lt;/a&gt;    ports:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-5"&gt;&lt;/a&gt;        - '80:80'
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-6"&gt;&lt;/a&gt;        - '443:443'
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-7"&gt;&lt;/a&gt;    volumes:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-8"&gt;&lt;/a&gt;        - ./www:/var/www
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-9"&gt;&lt;/a&gt;        - ../storage:/mnt
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-10"&gt;&lt;/a&gt;        - /etc/localtime:/etc/localtime:ro
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-11"&gt;&lt;/a&gt;    links:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-12"&gt;&lt;/a&gt;        - letsencrypt
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-13"&gt;&lt;/a&gt;        - nextcloud
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-14"&gt;&lt;/a&gt;        - collabora
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-15"&gt;&lt;/a&gt;        - transmission
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-16"&gt;&lt;/a&gt;    volumes_from:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-17"&gt;&lt;/a&gt;        - letsencrypt
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-18"&gt;&lt;/a&gt;    depends_on:
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-19"&gt;&lt;/a&gt;        - letsencrypt
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-20"&gt;&lt;/a&gt;        - nextcloud
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-21"&gt;&lt;/a&gt;        - transmission
&lt;a name="rest_code_d52b9a6ea6234f72af7bdf01c23cec28-22"&gt;&lt;/a&gt;    restart: always
&lt;/pre&gt;&lt;p&gt;Well this is where things started going downhill and eventually took me a couple days till I found something online that pointed me in the right direction. Long story short, if you are going to run a webserver and a separate &lt;tt class="docutils literal"&gt;fpm&lt;/tt&gt; docker images, you have to have all URL paths be exactly the same. Both docker containers need to be able to look things up the same way, even as strict as file pathing. To solve this, I renamed my &lt;tt class="docutils literal"&gt;nextcloud&lt;/tt&gt; directory that was in the &lt;tt class="docutils literal"&gt;www&lt;/tt&gt; to &lt;tt class="docutils literal"&gt;html&lt;/tt&gt;. This made my &lt;tt class="docutils literal"&gt;nginx&lt;/tt&gt; container match the &lt;tt class="docutils literal"&gt;nextcloud&lt;/tt&gt; container paths and solved all 404 errors I had been getting. Hopefully this saves someone or my future self some hours going forward knowing this.&lt;/p&gt;
&lt;p&gt;Outside of those hurdles I had to deal with, docker has been fun to learn and understand all the black magic that goes along with it. For those interested, you can find the latest state of my docker-compose file on my &lt;a class="reference external" href="https://github.com/willdeberry/home-server"&gt;github&lt;/a&gt;.&lt;/p&gt;&lt;/div&gt;</description><category>docker</category><category>esxi</category><category>vm</category><guid>https://sudoservers.com/posts/move-all-the-things-to-docker/</guid><pubDate>Wed, 12 Jul 2017 02:02:12 GMT</pubDate></item></channel></rss>