{"id":565,"date":"2021-01-25T23:40:44","date_gmt":"2021-01-26T04:40:44","guid":{"rendered":"https:\/\/www.unliterate.net\/?p=565"},"modified":"2021-01-25T23:40:44","modified_gmt":"2021-01-26T04:40:44","slug":"learning-docker-take-1","status":"publish","type":"post","link":"https:\/\/www.unliterate.net\/index.php\/2021\/01\/25\/learning-docker-take-1\/","title":{"rendered":"Learning Docker: Take 1"},"content":{"rendered":"\n<p>It was time. I&#8217;ve been waiting for enough time to learn Docker and begin to get familiar with it. I&#8217;ve heard of it, seen it in action, and thought it was the coolest thing in the world and I had to learn it. I decided to take the dive off the actual Docker ship and descend into the depths.<\/p>\n\n\n\n<p>So, I found a YouTube video from the Docker YouTube video channel (link: <a rel=\"noreferrer noopener\" href=\"https:\/\/youtu.be\/iqqDU2crIEQ\" target=\"_blank\">https:\/\/youtu.be\/iqqDU2crIEQ<\/a>). Albeit it provided me some terminology and knowledge, it didn&#8217;t really tell me everything I wanted to know, like some under-the-core or how docker did the docker thing. I learned how to build, ps, port forward, <a href=\"https:\/\/hub.docker.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">docker hub<\/a>, and a <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\" target=\"_blank\">Dockerfile<\/a>, but then they went to <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.docker.com\/compose\/install\/\" target=\"_blank\">docker-compose<\/a> and I got lost.<\/p>\n\n\n\n<p>So, after sitting on that video and registering all the information I decided to set a goal: Load minecraft in a docker container. This shouldn&#8217;t be difficult, as it requires java, some source files, and that should be simple.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>Firstly I had to get myself a Virtual Machine. I fired up <a rel=\"noreferrer noopener\" href=\"https:\/\/www.virtualbox.org\/\" target=\"_blank\">VirtualBox<\/a> and a Centos 7 image with 2 CPU, 4GB RAM, and 20gb of SSD storage. yum update and yum installed docker (2:1.13.1-203.git0be3e21.el7.centos), and I was good to go. Starting the docker service wasn&#8217;t really part of the instructions, but on noticing the errors I was getting executing docker I realized it was something that needed to happen.<\/p>\n\n\n\n<p>Getting Minecraft wasn&#8217;t difficult, as I just had to go to their <a rel=\"noreferrer noopener\" href=\"https:\/\/www.minecraft.net\/en-us\/download\/server\/\" target=\"_blank\">Server Download URL<\/a> and grab the jar. I provided it a eula.txt and a proper server.properties, which is needed for minecraft to properly launch.<\/p>\n\n\n\n<p>Now I had to make myself a Dockerfile. I knew I&#8217;d need Java, and hub gave me <a rel=\"noreferrer noopener\" href=\"https:\/\/hub.docker.com\/_\/openjdk\" target=\"_blank\">openjdk:7<\/a> to use. The rest of the Dockerfile was to copy files, set the working directory, and then execute Minecraft. I pulled my command-line from my actual Minecraft Server as reference and converted it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>FROM openjdk:7\n\rCOPY . .\r\nWORKDIR .\r\nCMD &#91;\"java\", \"-Xmx2048M\", \"-Xms2048M\", \"-jar\", \"minecraft-server.jar\", \"nogui\"]\r<\/code><\/pre>\n\n\n\n<p>On executing the above I got some Java Version issue, and Minecraft wouldn&#8217;t launch. Changing <em>openjdk:7<\/em> to <em>openjdk:8<\/em> solved this quite well.<\/p>\n\n\n\n<p>So, now i&#8217;ve got my Docker image launched! After connecting to it and learning that it couldn&#8217;t authenticate me due to a failure to connect to the mojang authentication server I learned that Docker is dependent on the machines network, including DNS, and I failed to set up DNS. On setting up a correct <em>\/etc\/resolve.conf<\/em> and restarting the image I was able to connect to my first Docker minecraft server!<\/p>\n\n\n\n<p>On pulling up some system resources I learned that Java was actually allocating all the ram that I specified on the command-line (50% of the VM), and I didn&#8217;t really think it needed to be doing that at the start. On removing the -Xmx and -Xms parameters and rebuilding it seemed the application still loaded, but just ran with &lt;20% of the necessary RAM.<\/p>\n\n\n\n<p>There is no current disk persistence of the world, which would be a logical next step. For now, <strong>Take 1<\/strong> was successful!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It was time. I&#8217;ve been waiting for enough time to learn Docker and begin to get familiar with it. I&#8217;ve heard of it, seen it in action, and thought it was the coolest thing in the world and I had to learn it. I decided to take the dive off the actual Docker ship and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,9,20,17],"tags":[],"class_list":["post-565","post","type-post","status-publish","format-standard","hentry","category-centos","category-gaming","category-geek-instructions","category-linux"],"_links":{"self":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/565","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/comments?post=565"}],"version-history":[{"count":1,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/565\/revisions"}],"predecessor-version":[{"id":566,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/posts\/565\/revisions\/566"}],"wp:attachment":[{"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/media?parent=565"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/categories?post=565"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.unliterate.net\/index.php\/wp-json\/wp\/v2\/tags?post=565"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}