{"id":115,"date":"2016-11-17T04:27:01","date_gmt":"2016-11-17T04:27:01","guid":{"rendered":"http:\/\/10.0.3.2\/wordpress\/?p=115"},"modified":"2018-04-27T09:41:38","modified_gmt":"2018-04-27T09:41:38","slug":"lxc-container","status":"publish","type":"post","link":"https:\/\/info.juliusgoh.life\/?p=115","title":{"rendered":"Lxc Container"},"content":{"rendered":"<pre>\r\nlxc-create -t download -n my-container\r\n<\/pre>\n<p>The download template will show you a list of distributions, versions and architectures to choose from.<br \/>\nA good example would be &#8220;ubuntu&#8221;, &#8220;trusty&#8221; (14.04 LTS) and &#8220;i386&#8221;.<\/p>\n<p>How to ssh into lxc as root:<\/p>\n<pre>\r\n1:lxc-attach -n my-container\r\n2:to apt-get install ssh\r\n3:vim \/etc\/ssh\/sshd_config\r\n4:Go to line 28: \"PermitRootLogin\" Change it to yes\r\n5:Then you're allow to ssh into root\r\n6:Remember to set a password before logging out\r\n7.\/etc\/init.d\/ssh restart\r\n\r\n8:After logging out there is one more thing you have to do, you have to assign IP to that lxc\r\n  in order to ssh into that lxc.\r\n9:At your host , vim \/var\/lib\/my-container\/config\r\n10:Add\r\nlxc.network.ipv4 = 10.0.3.4 (According to gateway IP)\r\nlxc.network.ipv4.gateway = 10.0.3.1\r\n\r\n11.(Optional) when you use lxc-ls -f you will see your container is having two ip , one is the one you set and one is the dhcp ip , you can remove it by edit \/etc\/network\/interfaces in your container, remove the line below auto eth0 \r\n\r\n\r\n<\/pre>\n<p>To Set lxc&#8217;s core and Ram<br \/>\nput below code in \/var\/lib\/lxc\/container-name\/config<\/p>\n<pre>\r\nlxc.cgroup.cpuset.cpus = 0,1\r\nlxc.cgroup.memory.soft_limit_in_bytes = 268435456\r\nlxc.cgroup.memory.limit_in_bytes = 1073741824\r\n<\/pre>\n<p>Host Network subnet information is at \/etc\/default\/lxc-net . For more information about making subnet or set your own range of ip&#8217;s , <a href=\"https:\/\/wiki.debian.org\/LXC\/SimpleBridge\">https:\/\/wiki.debian.org\/LXC\/SimpleBridge<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>lxc-create -t download -n my-container The download template will show you a list of distributions, versions and architectures to choose from. A good example would be &#8220;ubuntu&#8221;, &#8220;trusty&#8221; (14.04 LTS) and &#8220;i386&#8221;. How to ssh into lxc as root: 1:lxc-attach -n my-container 2:to apt-get install ssh 3:vim \/etc\/ssh\/sshd_config 4:Go to line 28: &#8220;PermitRootLogin&#8221; Change it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":214,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/115"}],"collection":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=115"}],"version-history":[{"count":7,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions"}],"predecessor-version":[{"id":407,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/posts\/115\/revisions\/407"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=\/wp\/v2\/media\/214"}],"wp:attachment":[{"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/info.juliusgoh.life\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}