转自:http://www.hyggeit.dk/2014/02/virtual-servers-on-raspberry-pi-with.html

Virtual servers on a Raspberry Pi with the light weight OS virtualization system Docker!

Virtual servers on a Raspberry Pi with the light weight OS virtualization system, Docker!

I find my self reinstalling the OS on my Raspberry pi all the time because I use my Pi to develop software, and install a lot of software packages, all the time. Sometimes you do experiments where you just can't go back and sometimes you need a clean slate
for trying something out. Therefore I was looking for a way to install software, try it out and discard it, in a way that's fast and easy. I also want to isolate my installations sometimes, and sometimes run more than one copy of one piece of software which
of course requires some virtual machines. 



The solution is Docker!



Docker is a light weight OS virtualization system which makes it possible to run  more than one OS on the same hardware and makes it extremely easy to install a new OS, use it and discard it. Another cool feature is that you can download, install, and start
an OS with preinstalled software like Owncloud with just one command! Docker also makes your installations portable so you can easily move or clone your installations.

Let's install Docker on your Raspberry Pi!



This is what you need:

  • A Raspberry Pi, of course!
  • A keyboard
  • Network connection
  • A screen
  • and a fast SD-card, mine can transfer 60 M/s which is recommended.

Install Arch Linux on the SD-card

We will now install Arch Linux on your SD-card.



If you are preparing your SD-card on a Win or Mac machine, the instructions for installing Arch Linux on the SD-card can be found here: 



http://archlinuxarm.org/platforms/armv6/raspberry-pi



1.  Download the disk images:



$ wget http://archlinuxarm.org/os/ArchLinuxARM-rpi-latest.zip



2.  Unpack ArchLinuxARM-rpi-latest.zip



$ unzip ArchLinuxARM-rpi-latest.zip



3.  Find out the path for you SD-card. At my system it's /dev/sdb

Note: You can use Gparted to find the path. We will also use this application later on in this tutorial.  



$ sudo dd bs=1M if=ArchLinuxARM-2014.02-rpi.img of=/dev/sdb



Be patient, it will take 10+ minutes and there will be no sign of life while it's going on. 

When it's done it will write a few statistics, which also tells you that it's done.



1960837120 byte (2,0 GB) kopieret, 338,551 s, 5,8 MB/s



4.  Run this command to ensure that everything have been written to the SD-card:



$ sudo sync



By default, the partition doesn’t fill the entire SD-card which means that you can't use all the space. Therefore we will extend the partitions to make more space for our data.



5.  Start Gparted:



$ sudo gparted



Install if necessary...

  1. Choose the right storage in the top right menu. Mine is /dev/sdb.
  2. Right click on the partition /dev/sdb2 (extented) and choose modify/move.
  3. Move the black arrow pointing right over to the right and press modify/move.
  4. Do the same with /dev/sdb5 (ext4).
  5. Press the green okay icon on the top to apply all the changes.
  6. After a little while it all done and you can close the application at take out the SD-card.

Let's get the power on!

Now it's time to start your installation for the first time!

  • Pop the SD-card in the the Pi.
  • Connect keyboard, network-cable and the HDMI-cable. Note:When everything is connected you connect the power.

1.  At this time we don't know the IP-address of the Raspberry Pi so we will log on locally. Log on with the user root and the password root.



Run this command to find the IP of your Pi:



$ ifconfig



Sometime it's easier to look the IP op through your routers webinterface.

Now when we know the IP we logout by type exit and press [Enter] And use our laptop instead.



2.  Start and terminal and connect to the Pi:



$ ssh root@192.168.1.123



Password is still root! It's a good idea as you might want to expose your Raspberry Pi to the internet at some point.



3.  Change the password by running:



$ passwd root



Write down the password.. Maybe on the back of the Pi ;-) If you're a numpty and forget to do this, then at some point you'll probably forget it. Then you should check out this post onHappy
Geekend
 for changing a password if you've completely forgotten it :)

And then the installation of Docker

1.  Download and install Kernel modules and Docker by:



$ wget https://raw.github.com/resin-io/docker-install-script/master/install.sh | sh



2.  We want each of the containers (the virtual machines) to have access to the network and internet and therefore we have to enable IP forwardingby running this command:



$ echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.d/40-ip-forward.conf



To have the newest features we will now upgrade Docker.



3.  Download by running this command:



$ wget https://github.com/resin-io/lxc-docker-PKGBUILD/releases/download/v0.7.5-1/docker-0.7.5-1-armv6h.pkg.tar.xz



You can look for newer version at this address:

https://github.com/resin-io/lxc-docker-PKGBUILD/releases



4.  Install by running:



$ pacman -U docker-0.7.5-1-armv6h.pkg.tar.xz



5.  Answer Y to all the questions.



6. To ensure that Docker will start automatically when the Raspberry Pi is turned on:



$ systemctl enable docker.service



7.  The system has to be rebooted before we can use it, as the kernel has been modified and these modifications will only be loaded doing boot.



Run:



$ systemctl reboot



Docker version 0.8.0 is out! But it doesn’t seem to be rock solid yet so I will suggest that you stick with Docker 0.7.5 for a little while.

It's time for testing!

1.  If, for example, you want an Owncloud installation (it's like Dropbox), up and running then connect through ssh as we did before, and run:



docker run -d -i -t -p 443:443 -p 80:80 comzone/rpi-owncloud6



2.  When it's up and running, open you webbrowser and go to the IP of your Raspberry pi!

To find many other ready to run installations, search for RPI at: https://index.docker.io/





Only installations which are made for the Raspberry Pi will run!



Everything with docker is managed with the Docker command.



Here are some hints:

  • To see all of your containers and their IDs:

$ docker ps

  • To attach to a container run:

$ docker attach ID



You have to replace the ID with the id number of the container you cant to manage.

  • To delete an container:

$ docker stop ID

$ docker rm ID

Tuning

You might want to consider tuning your Raspberry Pi so your CPU runs faster.

Be aware the some SD-cards can become corupted when the Raspberry Pi is tuned. If that happens then you have to reinstall the SD-card again.



It's easy to do!

1.  Install an editor, I prefer Nano:



$ pacman -S nano



2.  Edit the configurationfile for the Pi:



$ nano /boot/config.txt



3.  Uncomment the configuration-group you like. 1Gz is a good speed:





arm_freq=1000

core_freq=500

sdram_freq=500

over_voltage=6

4.  Press [CTRL]+x to save and exit.



The change will take place after next reboot so run:



$ sudo systemctl reboot





Happy Geekend!



Handy links:

http://resin.io/blog/docker-on-raspberry-pi-in-4-simple-steps/

http://docker.io

http://archlinuxarm.org/platforms/armv6/raspberry-pi

http://happygeekend.blogspot.dk

Virtual servers on a Raspberry Pi with the light weight OS virtualization system Docker!的更多相关文章

  1. Raspberry Pi Kernel Compilation 内核编译官方文档

    elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: S ...

  2. Cross-compiling Qt Embedded 5.5 for Raspberry Pi 2

    This tutorial shows how to cross-compile the Embedded build of Qt 5.5 for Raspberry Pi 2. The Embedd ...

  3. Roomblock: a Platform for Learning ROS Navigation With Roomba, Raspberry Pi and RPLIDAR(转)

      What is this? "Roomblock" is a robot platform consists of a Roomba, a Raspberry Pi 2, a ...

  4. Raspberry Pi GPIO Protection

    After damaging the GPIO port on our raspberry pi while designing a new solar monitoring system we de ...

  5. Raspberry Pi 4B 使用OpenCV访问摄像头picamera模块

    目录 1.OpenCV安装 (1)安装依赖 (2)下载OpenCV源码 (3)安装pip (4)安装Python虚拟机 (5)编译OpenCV (6)验证安装 2.使用OpenCV和Python控制摄 ...

  6. 【树莓派】【转】将树莓派Raspberry Pi设置为无线路由器(WiFi热点AP,RTL8188CUS芯片)

    下文为转载,文章转自:http://wangye.org/blog/archives/845/,仅供本次学习实践参考. 最近又开始折腾起Raspberry Pi来了,因为某处上网需要锐捷拨号,于是我就 ...

  7. RASPBERRY PI 外设学习资源

    参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get st ...

  8. 将树莓派Raspberry Pi设置为无线路由器(WiFi热点AP,RTL8188CUS芯片)

    http://wangye.org/blog/archives/845/ 最近又开始折腾起Raspberry Pi来了,因为某处上网需要锐捷拨号,于是我就想能不能让我的树莓派代劳,当然首先要将其改造为 ...

  9. Arduino VS. Raspberry Pi VS. Beaglebone Black

    The Arduino is a small Atmel-based microcontroller development board easily integrated into many dif ...

随机推荐

  1. Linux中tty是什么(tty1~7)

    tty:终端设备的统称. tty一词源于Teletypes,或者teletypewriters,原来指的是电传打字机,是通过串行线用打印机键盘通过阅读和发送信息的东西,后来这东西被键盘与显示器取代,所 ...

  2. hdu1209(Clock)

    pid=1209">点击打开hdu1209 Problem Description There is an analog clock with two hands: an hour h ...

  3. C语言数组和函数实例练习(二)

    1.C语言中不允许函数的嵌套定义,但可以使用函数的嵌套调用. 例1:输入4个整数,找出其中最大的数. #include <stdio.h> #include <stdlib.h> ...

  4. windows下mysql5.6.20使用mysqldumpslow.pl分析慢日志

    要想执行mysqldumpslow.pl(这是perl程序),下载perl编译器. 下载地址:http://pan.baidu.com/s/1i3GLKAp 就是ActivePerl_5.16.2.3 ...

  5. zoj3822 Domination 概率dp --- 2014 ACM-ICPC Asia Mudanjiang Regional Contest

    一个n行m列的棋盘,每次能够放一个棋子.问要使得棋盘的每行每列都至少有一个棋子 须要的放棋子次数的期望. dp[i][j][k]表示用了k个棋子共能占据棋盘的i行j列的概率. 那么对于每一颗棋子,在现 ...

  6. 文字录入无限制Undo,Redo的实现

    这里只针对Edit的内容做一个简单的undo,redo功能: 原理就是,将新增字符和相关信息添加到undo列表,在undo动作时,取记录信息,并在edit中删除新增的字符,然后将此动作添加到redo列 ...

  7. 基于aspectj的aop的操作

    1.引入相关的jar包 2.建两个类 public class Book { public void add(){ System.out.println("add-----------&qu ...

  8. Webpack 中的 Tree Shaking

    Tree Shaking Tree shaking 用于描述移除JavaScript上下文中的未引用代码(dead-code). 为了更方便地理解tree shaking,我们可以将应用程序想象成一棵 ...

  9. Mysql数据类型(二)

    字符类型 #官网:https://dev.mysql.com/doc/refman/5.7/en/char.html #注意:char和varchar括号内的参数指的都是字符的长度 #char类型:定 ...

  10. C#操作QQ邮箱发送电子邮件原来这么简单。。。。

    在贴代码之前,首先需要给QQ邮箱开服务IMAP/SMTP服务,详细开通方法见 "开通方法"(可能需要发送收费短信,所以只要开通这一个服务就好了). 这边主要就是为了一个服务的授权码 ...