{"id":48,"date":"2018-08-10T10:37:38","date_gmt":"2018-08-10T08:37:38","guid":{"rendered":"https:\/\/www.kth.se\/blogs\/pdc\/?p=48"},"modified":"2019-03-28T11:53:32","modified_gmt":"2019-03-28T10:53:32","slug":"skip-the-configuration-get-to-the-cluster-docker-way","status":"publish","type":"post","link":"https:\/\/www.kth.se\/blogs\/pdc\/2018\/08\/skip-the-configuration-get-to-the-cluster-docker-way\/","title":{"rendered":"Skip the configuration, get to the cluster: Docker way"},"content":{"rendered":"<div class=\"post-content-wrapper\"><p>Sometimes it can be a daunting task to get all the Kerberos and SSH configurations right on your first attempt at using the PDC systems.\u00a0Nearly every day PDC Support receives a number of help requests and questions from researchers who have run into configuration problems. So PDC has introduced an alternative way of logging in to our clusters by using Docker containers with pre-configured Kerberos and SSH files.<\/p>\n<h2>What is Docker?<\/h2>\n<p>Docker is a tool used to deploy and run single or many applications within what are known as containers. Containers are packed with all the parts that are needed to run an application, such as the actual application, any relevant tools, libraries or other necessary information. Each Docker container is delivered as a single package with all the necessary material included. This means that the person using the Docker container does not have to worry about installing any new tools\/libraries or configuring them before using them. Since everything is preloaded, the applications inside the containers are ready-to-use and can be executed regardless of any customized settings on the host machine.<\/p>\n<p>Later in this blog article, we will talk about a Docker container that we have developed for the purpose of logging in to PDC clusters.<\/p>\n<p><!--more--><\/p>\n<h2>Why not use a Virtual Machine (VM)?<\/h2>\n<p>In a way, Docker is a like a Virtual Machine (VM), but the difference is that instead of installing a whole new operating system, each Docker container only contains the parts of the operating system that are required by the applications in that particular container. Thus, unlike VMs, which each have an entire guest operating system, each Docker container runs as an isolated process in user space on the host operating system.\u00a0 This saves a lot of memory and makes it easier to use a container rather than a new operating system. Thus, Docker containers enjoy the resource isolation and allocation benefits of VMs but are much more portable and efficient.<\/p>\n<figure id=\"attachment_105\" aria-describedby=\"caption-attachment-105\" style=\"width: 625px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-105 size-medium\" src=\"https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container-625x255.png\" alt=\"\" width=\"625\" height=\"255\" srcset=\"https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container-625x255.png 625w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container-768x313.png 768w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container-900x367.png 900w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container-624x254.png 624w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Screenshot_2018-08-27-What-is-a-Container.png 1200w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><figcaption id=\"caption-attachment-105\" class=\"wp-caption-text\">Differences between Docker and Virtual Machines visualized (Source: docker.com\/resources\/what-container)<\/figcaption><\/figure>\n<p>Here we are focusing on using Docker to log in to PDC supercomputers, which is a relatively small task. Hence, we use the lighter Docker containers instead of actual VMs.<\/p>\n<h2>How to get started with Docker?<\/h2>\n<p>For logging in to our clusters here at PDC, we have created our own Docker container. To use it, you need to have Docker Toolbox installed on your system. You can find the instructions for installing Docker Toolbox on the operating system that you are currently using via the following links.<\/p>\n<p>Windows:\u00a0<a href=\"https:\/\/docs.docker.com\/toolbox\/toolbox_install_windows\/\">https:\/\/docs.docker.com\/toolbox\/toolbox_install_windows\/<\/a><br \/>\nUbuntu:\u00a0<a href=\"https:\/\/docs.docker.com\/install\/linux\/docker-ce\/ubuntu\/\">https:\/\/docs.docker.com\/install\/linux\/docker-ce\/ubuntu\/<\/a><br \/>\nMac:\u00a0<a href=\"https:\/\/docs.docker.com\/docker-for-mac\/install\/#install-and-run-docker-for-mac\">https:\/\/docs.docker.com\/docker-for-mac\/install\/#install-and-run-docker-for-mac<\/a><\/p>\n<p>When you have installed Docker Toolbox on your system, if you are using Windows or a Mac, you will find that you have a new terminal application, called Docker Terminal, installed on your system.\u00a0You can then use Docker Terminal for loading any Docker containers that you want to use. If you have a Ubuntu system, you can simply use Docker commands in your regular terminal. The docker installation links shown above for Windows and Mac are for the Docker toolbox versions only &#8211; these are lighter legacy versions of Docker CE. If you do not mind the huge size of the actual Docker CE software (~500MB), or if you will be performing more advanced tasks, you can find the links for installing the full Docker CE software in the &#8216;Get Docker&#8217; section of <a href=\"https:\/\/docs.docker.com\/\">https:\/\/docs.docker.com<\/a>.<\/p>\n<h2>A hub for the containers<\/h2>\n<p>Docker also provides a personal storage place for containers known as <a href=\"https:\/\/docs.docker.com\/docker-hub\/\">Docker Hub<\/a>.\u00a0 It is a cloud-based registry service which allows you to link to code repositories, build your own images, test them and store manually pushed images. In fact, we have created one container in our PDC repository on Docker Hub that we will be using in the upcoming steps.<\/p>\n<h2>Alright, can we login now?<\/h2>\n<p>Once you have installed Docker in your system, you can simply open the Docker Terminal on Windows or Mac, or your regular terminal on Ubuntu, and enter the command below to launch the container that we have created for you. Note: Make sure your system is connected to the Internet before you do this.<\/p>\n<pre>docker run -it pdcsupport\/pdclogin:latest<\/pre>\n<p>The <code>-it<\/code> flag in the command means that you want to run the Docker application interactively. If that flag is not used, the process will run in the background and has to be accessed separately later. <code>pdcsupport<\/code> is our Docker username, <code>pdclogin<\/code> is the name of a repository and <code>latest<\/code>\u00a0is the tag name given to our latest container in that repository.<\/p>\n<p>Once you have successfully loaded the PDC container, you can log in to any of the PDC host machines using two simple commands, as shown in the following example. You will need to give your username and the cluster you want to log in to.<\/p>\n<pre>kinit -f &lt;username&gt;@NADA.KTH.SE\r\nssh &lt;username&gt;@&lt;hostname&gt;.pdc.kth.se<\/pre>\n<p>Your screen output should look similar to the following image.<\/p>\n<figure id=\"attachment_108\" aria-describedby=\"caption-attachment-108\" style=\"width: 625px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-108 size-medium\" src=\"https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Capture-625x434.png\" alt=\"\" width=\"625\" height=\"434\" srcset=\"https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Capture-625x434.png 625w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Capture-624x433.png 624w, https:\/\/www.kth.se\/blogs\/pdc\/files\/2018\/08\/Capture.png 756w\" sizes=\"auto, (max-width: 625px) 100vw, 625px\" \/><figcaption id=\"caption-attachment-108\" class=\"wp-caption-text\">Logging in to Beskow with Docker<\/figcaption><\/figure>\n<p>Now you should be logged in and able to use our machines. Isn\u2019t that easy!<\/p>\n<p>Basically, <code>kinit<\/code> is a Kerberos command used to create a ticket which is stored locally in your system. It is then forwarded to the host machine when you try logging in using the <code>ssh<\/code> command. If you want to learn more about how <code>kinit<\/code> and <code>ssh<\/code> work at PDC, you can find some information <a href=\"https:\/\/www.pdc.kth.se\/support\/documents\/login\/login.html\">here<\/a>.<\/p>\n<h2>File sharing between Docker and host machines<\/h2>\n<p>Sometimes you will need to transfer files from your local system to the PDC host machine. To do this with Docker, you need to map a folder in your local system to a folder inside the PDC container. To do this use the <code>-v<\/code>\u00a0flag when launching the PDC container.<\/p>\n<pre>docker run -it \\\r\n    -v &lt;path-to-the-local-folder&gt;:\/root\/&lt;new-folder&gt; \\\r\n    pdcsupport\/pdclogin:latest<\/pre>\n<p>Note: Use the full path to your local folder rather than the relative path.<\/p>\n<p>You can now see your files inside the PDC Docker container in the path <code>root\/&lt;new-folder&gt;<\/code>. Any changes that are made to the folder in the local system will be reflected inside the <code>&lt;new-folder&gt;<\/code>\u00a0in the Docker container and vice versa.<\/p>\n<p>Now that your container has access to your data, meaning the files inside the specified folder, you can transfer data between your local system and the PDC host machines.\u00a0 To copy any file from the Docker container to the PDC host machine, you can use the <code>scp<\/code>\u00a0command, which uses the ssh protocol for secure transfers.<\/p>\n<pre># Copy a single file from local system to PDC host machine\r\nscp root\/&lt;fileToCopy&gt; \\\r\n    &lt;username&gt;@t04n28.pdc.kth.se:\/afs\/pdc.kth.se\/home<span style=\"background-color: #ffff00\">\/u\/user\/<\/span>\r\n<\/pre>\n<p>Please note the highlighted section of the command above. The path to your home folder in PDC&#8217;s AFS file system is actually\u00a0<code>\/afs\/pdc.kth.se\/home\/&lt;first-letter-of-your-username&gt;\/&lt;your-username&gt;<\/code>\u00a0however, in this article, we will just write\u00a0\u00a0<code>\/u\/user\/<\/code>\u00a0for the last two parts of the path to make things easier to read. You can find out more about file systems and data management at PDC\u00a0<a href=\"https:\/\/www.pdc.kth.se\/support\/documents\/data_management\/data_management.html\">here<\/a>.<\/p>\n<p>To copy entire folders you can use the <code>-r<\/code> flag as shown below.<\/p>\n<pre>#Copy a directory from local system to PDC host machine\r\nscp <span style=\"background-color: #ffff00\">-r<\/span> root\/&lt;dirToCopy&gt; \\\r\n    &lt;username&gt;@t04n28.pdc.kth.se:\/afs\/pdc.kth.se\/home\/u\/user\/&lt;dir&gt; \r\n<\/pre>\n<p>Bear in mind that you need to be in your Docker container, not on the PDC host machines, when using these file transfer commands. The general command usage is <code>scp -r &lt;source&gt; &lt;destination&gt;<\/code>. If you want to copy the files the other way around, that is, from a PDC cluster to your system, you still need to be in the Docker container and use the command in the following way.<\/p>\n<pre>#Copy a directory from PDC host machine to local system\r\nscp -r &lt;username&gt;@t04n28.pdc.kth.se:\/afs\/pdc.kth.se\/home\/u\/user\/&lt;dir&gt; \\\r\n    root\/&lt;dir&gt;<\/pre>\n<h2>Some things to remember<\/h2>\n<ol>\n<li>These procedures should be considered as an intermediate platform to make it easier for you to log in, and transfer files, from your local computer to a PDC system.<\/li>\n<li>The Docker container used at PDC is based on a lightweight version of Ubuntu 16.04 which only has basic built-in commands. You can however download our Docker image, and install other tools that you need in it.<\/li>\n<\/ol>\n<h2>Further Reading<\/h2>\n<p>If you would like to know more about Docker and how to use it, follow this <a href=\"https:\/\/docs.docker.com\/get-started\/\">link.<\/a><\/p>\n<p>If you encounter any difficulties when logging in during any of the above steps, please check our troubleshooting page <a href=\"https:\/\/www.pdc.kth.se\/support\/documents\/faq\/faq.html\">here<\/a>.<\/p>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Sometimes it can be a daunting task to get all the Kerberos and SSH configurations right on your first attempt at using the PDC systems.\u00a0Nearly every day PDC Support receives a number of help requests and questions from researchers who have run into configuration problems. So PDC has introduced an alternative way of logging in [&hellip;]<\/p>\n","protected":false},"author":1158,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[6],"tags":[16,15,17],"class_list":["post-48","post","type-post","status-publish","format-standard","hentry","category-environment-management","tag-container","tag-docker","tag-virtual-machine"],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p9W9Im-M","_links":{"self":[{"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/posts\/48","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/users\/1158"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/comments?post=48"}],"version-history":[{"count":37,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/posts\/48\/revisions"}],"predecessor-version":[{"id":388,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/posts\/48\/revisions\/388"}],"wp:attachment":[{"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/media?parent=48"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/categories?post=48"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kth.se\/blogs\/pdc\/wp-json\/wp\/v2\/tags?post=48"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}