{"id":3767,"date":"2017-10-27T23:58:25","date_gmt":"2017-10-27T19:58:25","guid":{"rendered":"https:\/\/nayarweb.com\/blog\/?p=3767"},"modified":"2017-10-28T00:49:31","modified_gmt":"2017-10-27T20:49:31","slug":"can-debian-stretch-run-on-ubuntu-16-04-lts-via-lxclxd","status":"publish","type":"post","link":"https:\/\/nayarweb.com\/blog\/2017\/can-debian-stretch-run-on-ubuntu-16-04-lts-via-lxclxd\/","title":{"rendered":"Can Debian Stretch run on Ubuntu 16.04 LTS via LXC\/LXD?"},"content":{"rendered":"<p>There is this never ending flame wars about whether Debian or Ubuntu is better. My personal servers have been historically on Ubuntu LTS due to the fact that they are known to have more updated packages that Debian. As I was planning to try MariaDB&#8217;s Galera cluster, I found that Debian Stretch has a more recent version of MariaDB than Ubuntu 16.04LTS.<\/p>\n<p>No problem! I&#8217;ll run MariaDB inside a Debian container rather than an Ubuntu&#8217;s one. Here&#8217;s how to proceed:<\/p>\n<blockquote><p># We download and create a container based on debian\/stretch and we&#8217;ll call the VM mariadb-1<\/p>\n<p><span class=\"s1\">lxc launch images:debian\/stretch mariadb-1<\/span><\/p>\n<p># We install an SSH server inside the VM to access it<\/p>\n<p class=\"p1\"><span class=\"s1\">lxc exec mariadb-1 &#8212; apt-get install ssh<\/span><\/p>\n<p># I put my public key inside the VM so that I can SSH into it.<\/p>\n<p># But before that, we need to create the .ssh directory<\/p>\n<p>lxc exec\u00a0<span class=\"s1\">mariadb-1 &#8212; sh -c &#8216;mkdir -p \/root\/.ssh\/&#8217;<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">lxc exec mariadb-1 &#8212; sh -c &#8216;echo &#8220;ssh-rsa AAAAB3N&#8230;+j\/ nayar@macbook.local&#8221; &gt; \/root\/.ssh\/authorized_keys&#8217;<\/span><\/p>\n<p># The keys should be readable only by the owner<\/p>\n<p>lxc exec\u00a0<span class=\"s1\">mariadb-1 &#8212; sh -c &#8216;chmod -R 600 \/root\/.ssh\/&#8217;<\/span><\/p><\/blockquote>\n<p>And now your container should be accessible via SSH. You can use it like a VM. You may use the command below to find it&#8217;s IP<\/p>\n<blockquote><p>lxc list<\/p>\n<p class=\"p1\"><span class=\"s1\">| mariadb-1 <span class=\"Apple-converted-space\">\u00a0 \u00a0 <\/span>| RUNNING | 10.195.197.123 (eth0)<\/span><\/p>\n<\/blockquote>\n<p>Tips: If by doing so, the VM still asks you for password while trying to ssh on it, make sure you have properly pushed your ssh agent. On your laptop, try the following<\/p>\n<blockquote><p>ssh-add -k<\/p>\n<p>ssh -A root@myserver.com &#8220;ssh root@<span class=\"s1\">10.195.197.123<\/span>&#8220;<\/p><\/blockquote>\n<p>Don&#8217;t repeat the same procedure for every container you need to create. Just copy from one:<\/p>\n<blockquote><p>lxc copy\u00a0<span class=\"s1\">mariadb-1\u00a0mariadb-2<\/span><\/p><\/blockquote>\n<p>There you go. You have a new container under 5 seconds. Hope you liked this mini tutorial. Feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is this never ending flame wars about whether Debian or Ubuntu is better. My personal servers have been historically on Ubuntu LTS due to the fact that they are known to have more updated packages that Debian. As I was planning to try MariaDB&#8217;s Galera cluster, I found that Debian Stretch has a more &hellip; <a href=\"https:\/\/nayarweb.com\/blog\/2017\/can-debian-stretch-run-on-ubuntu-16-04-lts-via-lxclxd\/\" class=\"continue-reading\">Continue reading <span class=\"screen-reader-text\">Can Debian Stretch run on Ubuntu 16.04 LTS via LXC\/LXD?<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[210],"tags":[61,208,235,209],"class_list":["post-3767","post","type-post","status-publish","format-standard","hentry","category-technology","tag-linux","tag-lxc","tag-lxd","tag-virtualisation"],"_links":{"self":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3767","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/comments?post=3767"}],"version-history":[{"count":3,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3767\/revisions"}],"predecessor-version":[{"id":3770,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/posts\/3767\/revisions\/3770"}],"wp:attachment":[{"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/media?parent=3767"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/categories?post=3767"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nayarweb.com\/blog\/wp-json\/wp\/v2\/tags?post=3767"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}