{"id":395,"date":"2020-10-27T20:00:26","date_gmt":"2020-10-28T00:00:26","guid":{"rendered":"http:\/\/wangxiaohu.com\/blog\/?p=395"},"modified":"2020-10-27T20:00:26","modified_gmt":"2020-10-28T00:00:26","slug":"running-docker-on-nexus-5","status":"publish","type":"post","link":"https:\/\/wangxiaohu.com\/blog\/?p=395","title":{"rendered":"Running docker on Nexus 5"},"content":{"rendered":"\n<p>My Raspberry Pi 3 died. It was used for running Plex server. It was running inside docker before the Pi died. I was looking for replacement. I looked into my basement and I found two\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/wiki.postmarketos.org\/wiki\/Google_Nexus_5_(lg-hammerhead)\" target=\"_blank\">Google_Nexus_5_(lg-hammerhead)<\/a>\u00a0phones. Then the story began&#8230;<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul><li>you are fairly familiar with how flashing works, e.g. fastboot stuff.<\/li><li>you&#8217;ve already running postmarketos on your phone<\/li><li>you know what docker is<\/li><li>you know that you are probably gonna remove all the fancy UIs from your phone, and switch to postmarketos-ui-fbkeyboard or some console only mode<\/li><li>you&#8217;d better have a LAN connection on your phone rather than wifi<\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Steps<\/h2>\n\n\n\n<p>I can only prove this is working on my phones for now.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>1. Edit kernel config<\/strong><\/h3>\n\n\n\n<p>NOTE: before you make any change to kernel, always backup\u00a0<code>~\/.local\/var\/pmbootstrap\/cache_git\/pmaports\/main\/linux-postmarketos-qcom-msm8974\/config-postmarketos-qcom-msm8974.armv7<\/code><\/p>\n\n\n\n<p>Run<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>pmbootstrap kconfig edit postmarketos-qcom-msm8974<\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>where\u00a0<strong><code>qcom-msm8974<\/code><\/strong>\u00a0is for my Nexus 5. You need to figure out what&#8217;s for your phone.<\/p>\n\n\n\n<p>You have 2 options to learn what to set when configuring the kernel:<\/p>\n\n\n\n<ul><li>follow\u00a0<a href=\"https:\/\/wiki.gentoo.org\/wiki\/Docker#Kernel\">https:\/\/wiki.gentoo.org\/wiki\/Docker#Kernel<\/a>\u00a0(which doesn&#8217;t really apply to kernel 5.9 but I made it)<\/li><li>run\u00a0<a href=\"https:\/\/raw.githubusercontent.com\/moby\/moby\/master\/contrib\/check-config.sh\">https:\/\/raw.githubusercontent.com\/moby\/moby\/master\/contrib\/check-config.sh<\/a><\/li><\/ul>\n\n\n\n<p>You can see the changes I made to my kernel config at&nbsp;<a href=\"https:\/\/gitlab.com\/tigerinus\/pmaports\/-\/commit\/d4c1ad862f5485fd9a7577e59b95e97da1b988ae\">https:\/\/gitlab.com\/tigerinus\/pmaports\/-\/commit\/d4c1ad862f5485fd9a7577e59b95e97da1b988ae<\/a><\/p>\n\n\n\n<p>BTW &#8211; I&#8217;ve got a Ugreen USB 2.0 network adapter hooked, so I took the chance and selected<\/p>\n\n\n\n<p><strong><code>Device Drivers => Network device support => &lt;*> USB Network Adapters => &lt;*> ASIX AX88xxx Based USB 2.0 Ethernet Adapters<\/code><\/strong>\u00a0<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>2. Build the kernel<\/strong><\/h3>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>pmbootstrap build linux-postmarketos-qcom-msm8974 --force <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>I had to add\u00a0<strong><code>--force<\/code><\/strong>\u00a0otherwise it won&#8217;t build.<\/p>\n\n\n\n<p>If everything is successful, you should find something like below<\/p>\n\n\n\n<p><code>~\/.local\/var\/pmbootstrap\/packages\/edge\/armv7\/linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>3. Install the kernel<\/strong><\/h3>\n\n\n\n<p>Get the&nbsp;<strong>linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk<\/strong>&nbsp;copied onto your phone and do<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo apk add -u linux-postmarketos-qcom-msm8974-5.9.0_rc4-r0.apk <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>Just in case, I also copied\u00a0<strong><code>\/boot\/boot.img-postmarketos-qcom-msm8974<\/code><\/strong>\u00a0to local as\u00a0<strong><code>boot.img<\/code><\/strong>, boot to bootloader and did<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>fastboot flash boot boot.img <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>Reboot the phone and run\u00a0<strong><code>check-config.sh<\/code><\/strong>\u00a0again to see if anything missing. My experience is you don&#8217;t need everything enabled.<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wiki.postmarketos.org\/images\/c\/c3\/Check-config.png?w=660&#038;ssl=1\" alt=\"\" data-recalc-dims=\"1\"\/><\/figure><\/div>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>4. Install docker<\/strong><\/h3>\n\n\n\n<p>Boot to your phone, assuming you have a pretty good internet connection, then do<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo apk add docker<\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>Not only this installs docker, but also an important service\u00a0<strong><code>containerd<\/code><\/strong>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>5. Get docker daemon running<\/strong><\/h3>\n\n\n\n<p>Run<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo service docker start <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>We are not there yet. This first-time boot is for creating files, directories, group it needs. The\u00a0<code><strong>docker<\/strong>\u00a0<\/code>command won&#8217;t work because of couple things that have to happen at boot time below.<\/p>\n\n\n\n<p>DO NOT make docker to start on boot or you will get &#8220;can&#8217;t load program: function not implemented: unknown.&#8221; error.<\/p>\n\n\n\n<p>BTW &#8211; If you hate doing\u00a0<strong><code>sudo docker...<\/code><\/strong>\u00a0everytime, you can optionally add yourself to docker group by<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo vi \/etc\/group <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>Now reboot so at least\u00a0<code><strong>containerd<\/strong>\u00a0<\/code>service is effective, in terms of automatically mounting\u00a0<code><strong>cgroup2<\/strong>\u00a0<\/code>to\u00a0<strong><code>\/sys\/fs\/cgroup<\/code><\/strong>.<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo reboot <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>After reboot, do<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p><code><em>sudo service docker start <\/em><\/code><\/p><\/blockquote>\n\n\n\n<p>You should see something like<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wiki.postmarketos.org\/images\/7\/7e\/Sudo_service_docker_start.png?w=660&#038;ssl=1\" alt=\"Sudo service docker start.png\" data-recalc-dims=\"1\"\/><\/figure><\/div>\n\n\n\n<p>which you won&#8217;t see if you tried to start docker service before the reboot.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>6. Verify things are good<\/strong><\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wiki.postmarketos.org\/images\/3\/34\/Docker_info.png?w=660&#038;ssl=1\" alt=\"Docker info.png\" data-recalc-dims=\"1\"\/><figcaption>health check<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wiki.postmarketos.org\/images\/0\/08\/Docker_run_hello_world.png?w=660&#038;ssl=1\" alt=\"Docker run hello world.png\" data-recalc-dims=\"1\"\/><figcaption>hello-world<\/figcaption><\/figure><\/div>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/i0.wp.com\/wiki.postmarketos.org\/images\/9\/96\/Docker_run_fedora.png?w=660&#038;ssl=1\" alt=\"Docker run fedora.png\" data-recalc-dims=\"1\"\/><figcaption>fedora<\/figcaption><\/figure><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s next?<\/h2>\n\n\n\n<p>It&#8217;d be fun to have kubernetes running on this little device. Not sure if I should go with <a href=\"https:\/\/k3s.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">k3s <\/a>or <a href=\"https:\/\/microk8s.io\/\" data-type=\"URL\" data-id=\"https:\/\/microk8s.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">microk8s<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">References<\/h2>\n\n\n\n<ul><li><a href=\"https:\/\/wiki.alpinelinux.org\/wiki\/Docker\">https:\/\/wiki.alpinelinux.org\/wiki\/Docker<\/a><\/li><\/ul>\n\n\n\n<ul><li><a href=\"https:\/\/wiki.gentoo.org\/wiki\/Docker#Kernel\">https:\/\/wiki.gentoo.org\/wiki\/Docker#Kernel<\/a><\/li><\/ul>\n\n\n\n<ul><li><a href=\"https:\/\/blog.hypriot.com\/post\/verify-kernel-container-compatibility\/\">https:\/\/blog.hypriot.com\/post\/verify-kernel-container-compatibility\/<\/a><\/li><\/ul>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>My Raspberry Pi 3 died. It was used for running Plex se &hellip; <a href=\"https:\/\/wangxiaohu.com\/blog\/?p=395\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">Running docker on Nexus 5<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[1],"tags":[47,49,50,48],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","jetpack_likes_enabled":true,"jetpack-related-posts":[],"jetpack_shortlink":"https:\/\/wp.me\/pdhZ2A-6n","_links":{"self":[{"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/395"}],"collection":[{"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395"}],"version-history":[{"count":7,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions"}],"predecessor-version":[{"id":402,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/395\/revisions\/402"}],"wp:attachment":[{"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wangxiaohu.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}