{"id":930,"date":"2018-04-03T19:59:04","date_gmt":"2018-04-03T19:59:04","guid":{"rendered":"http:\/\/www.codeastar.com\/?p=930"},"modified":"2018-04-04T12:41:50","modified_gmt":"2018-04-04T12:41:50","slug":"install-docker-raspberry-pi","status":"publish","type":"post","link":"https:\/\/www.codeastar.com\/install-docker-raspberry-pi\/","title":{"rendered":"How to install Docker on Raspberry Pi"},"content":{"rendered":"
In this article, we will talk about Docker and Raspberry Pi.\u00a0Docker is a platform you may probably hear it often recently. It is hot because it helps people simplify the DevOps process. It lets developers build light-weight applications. Then they can ship and run their applications “anywhere” (we will discuss it in later section).\u00a0On the other hand, Raspberry Pi is a low cost, credit card sized\u00a0complete computer. It is good for being used in education, development<\/a> and IoT (Internet of Thing)! So what if we combine these 2 things together? We can use Docker to run different kind of applications on Raspberry Pi! Booyah! (ideally)<\/p>\n <\/p>\n Let’s get back to basics. What is Docker and why is it so popular? Docker is a platform which allows people running different kinds of applications on it. Oh yeah, you may think it is nothing new as virtual machines have already done this for long. Yes, but the beautiful part of Docker is, all of those applications are running under one single Docker engine. Unlike the case of virtual machines installing different guest OSes on a host machine, Docker only installs runtime libraries for related applications. Thus Docker can save more resources on host’s machine and provide faster start up time.<\/p>\n Other than resource saving, Docker can bring standards to development team.\u00a0Developers in the team use Docker to build an image, share with teammates and push it on testing environment.\u00a0When there were bugs, they can fix them on development environment. Then they rebuild and redeploy it to testing environment with Docker. Once everything is fine, they can use Docker to deploy the same image to production environment. At the end, developers use Docker to work on the same image in different environments.<\/p>\n We can visit official Docker web<\/a> site for installing process. It will be easier if we install Docker in Windows or Mac OS. Since we are going to install Docker on Raspberry Pi, it will just add a few more steps.<\/p>\n First things first, we go for some preparation work:<\/p>\n Login our Raspberry Pi and run following command<\/p>\n It will print out the info of our system.<\/p>\n Obviously, my Raspberry Pi is called “codearasp” and it is using a 32-bit “armv7I” kernel.<\/p>\n Or you can use following command<\/p>\n To see the OS of our Raspberry Pi.<\/p>\n I would recommend installing Docker with at least Raspbian Jessie OS. You can also visit Docker official installation document for Raspbian\u00a0here<\/a>.<\/p>\n We are just 5 more steps away to have Docker on our Raspberry Pi. Let’s do it!<\/p>\n 1 – Get the updated version for packages stored in our system<\/em><\/p>\n 2 – Get necessary packages to install Docker on our system<\/em><\/p>\n 3 – Get the official GPG encrypted key from Docker web site<\/em><\/p>\n The purpose of this step is to ensure we are downloading Docker files from the official Docker source.<\/p>\n 4 – Setup the stable repository from Docker web site for installing Docker<\/em><\/p>\n 5 – Finally, we are going to install it!\u00a0<\/em><\/p>\n First, we run the update command again to update packages’ version, as we have just added a Docker repository.<\/p>\n Then we install Docker from the repository.<\/p>\n Ta-Da! Docker is now installed on our Raspberry Pi device.<\/p>\n The best way to verify our Docker installation, is to run a Docker command on it. So we run the following command:<\/p>\n Docker will then try to run an “hello-world” image.<\/p>\n A “Hello from Docker on armhf!” message will appear if nothing goes wrong. Docker is ready on our Raspberry Pi, let’s try different Docker image from Docker Hub<\/a>!<\/p>\n “Build once, run anywhere” is a feature of Docker. But well, it is just not the story for Raspberry Pi. Since Docker on Raspberry Pi is using armv7\/6 architecture currently, it can only work with Docker images built from armv7\/6. e.g. a Raspberry Pi Docker can run an image built from Raspberry Pi, but not from Mac OS. ( p.s. “Build once, run anywhere” is still valid for Docker on X86_64 machines)<\/p>\nWhat is Docker?<\/h3>\n
Enough talking, let’s install!<\/h3>\n
$uname -a\r\n<\/pre>\n
Linux codearasp 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l GNU\/Linux\r\n<\/pre>\n
$cat \/etc\/os-release\r\n<\/pre>\n
PRETTY_NAME=\"Raspbian GNU\/Linux 9 (stretch)\"\r\nNAME=\"Raspbian GNU\/Linux\"\r\nVERSION_ID=\"9\"\r\nVERSION=\"9 (stretch)\"\r\nID=raspbian\r\nID_LIKE=debian\r\n<\/pre>\n
5 steps to install Docker on Raspberry Pi<\/h3>\n
$sudo apt-get update\r\n<\/pre>\n
$sudo apt-get install apt-transport-https \\\r\n ca-certificates \\\r\n software-properties-common\r\n<\/pre>\n
$curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo apt-key add -\r\n<\/pre>\n
$echo \"deb [arch=armhf] https:\/\/download.docker.com\/linux\/debian \\\r\n $(lsb_release -cs) stable\" | \\\r\n sudo tee \/etc\/apt\/sources.list.d\/docker.list\r\n<\/pre>\n
$sudo apt-get update\r\n<\/pre>\n
$sudo apt-get install docker-ce\r\n<\/pre>\n
Hello World, Docker<\/h3>\n
$sudo docker run armhf\/hello-world\r\n<\/pre>\n
Unable to find image 'armhf\/hello-world:latest' locally\r\nlatest: Pulling from armhf\/hello-world\r\na0691bf12e4e: Pull complete\r\nDigest: sha256:9701edc932223a66e49dd6c894a11db8c2cf4eccd1414f1ec105a623bf16b426\r\nStatus: Downloaded newer image for armhf\/hello-world:latest\r\n\r\nHello from Docker on armhf!\r\nThis message shows that your installation appears to be working correctly.\r\n<\/pre>\n
Reality vs Truth<\/h3>\n
<\/p>\n