Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to create your own Docker image on raspberry pie 2

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces how to create your own Docker image on raspberry pie 2. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.

Create your own Docker image on raspberry pie 2 [raspbian system]

It takes a long time to install a docker.io on my raspberry pie 2 yesterday (mainly due to the change of docker version, which leads to different descriptions in various tutorials, but the raspberry pie is not the latest version for apt-get installation). For details, please refer to the installation docker record under raspberry pie 2. I thought that then I could simply run a container according to the pull image described in various tutorials. As a result, I found that I was too optimistic!

Look at the version of docker we currently installed, it is not too high, now the official version seems to be 1.8.

Pi@rpi ~ / notebooks $sudo docker versionClient version: 1.3.3Client API version: 1.15Go version (client): go1.3.2Git commit (client): d344625OS/Arch (client): linux/armServer version: 1.3.3Server API version: 1.15Go version (server): go1.3.2Git commit (server): d344625pi@rpi ~ / notebooks $sudo docker infoContainers: 6Images: 4Storage Driver: devicemapper Pool Name: docker-179:2-73614-pool Pool Blocksize: 65.54 kB Data file: / var/ Lib/docker/devicemapper/devicemapper/data Metadata file: / var/lib/docker/devicemapper/devicemapper/metadata Data Space Used: 1.208 GB Data Space Total: 107.4 GB Metadata Space Used: 1.516 MB Metadata Space Total: 2.147 GB Library Version: 1.02.90 (2014-09-01) Execution Driver: native-0.2Kernel Version: 4.1.13-v7+Operating System: Raspbian GNU/Linux 8 (jessie) WARNING: No swap limit supportpi@rpi ~ / notebooks $

First execute this command sudo docker-d to get the daemon running.

Started to try to download the official image, basically every time pull will report an error, and none of the domestic companies seems to be able to pull down normally. At this time, I saw a company specially made a distribution of built-in docker for raspberry pie, which is this Getting started with Docker on your Raspberry Pi, but I think my raspbian is running well, and it is full of all kinds of software. It's not cost-effective to replace it all just to try docker. So this kind of plan will not be considered for the time being.

At this time, I began to think about creating my own image for docker. After searching for a long time, I found that there are basically two methods, as follows:

1 with debootstrap, unfortunately, execution on my raspberry pie 2 will return an error

2 use the `tar` command to package the currently used `raspbian` system, and then use the third method, try half of it, and find that the package is too big and give up halfway

3 find a Linux system `ISO` and import it to `docker image` using the `sudo docker import` command

4 find a Linux system `tar` package (just like the installation package) and import it as `docker image` using the `docker import` command

So now there is only the fourth way to work, there is a website OpenVZ specifically provides this kind of system package template, here downloaded several system templates back into docker image, can be successfully imported, but can not execute the command, guess may be because raspberry pie 2 needs a special ARMV7 version, and this site provides x86 version.

So we have to find a way to find the system package from other places, the most direct thing is to download it from each Linux official website and keep trying.

After losing one after another, there is finally the dawn of victory: ArchLinux with rootfs has succeeded as expected!

Get ArchLinux first. This version supports both the 1st and 2nd generations of raspberry pie:

Pi@rpi ~ / notebooks $wget http://212.187.212.74/bt/ab301ea7ea245c12ea9babf5235d75b04890bbd4/data/ArchLinuxARM-2014.10-rpi-rootfs.tar.gz--2015-12-30 1702VOULY-http://212.187.212.74/bt/ab301ea7ea245c12ea9babf5235d75b04890bbd4/data/ArchLinuxARM-2014.10-rpi-rootfs.tar.gzConnecting to 212.187.212.74VOV 80... Connected.HTTP request sent, awaiting response... 200 OKLength: 220637379 (210m) [application/x-gzip] Saving to: `ArchLinuxARM-2014.10-rpi-rootfs.tar.gz'74% [= >] 163600832 -.-K in 55m 51s2015-12-30 17:58:15 (47.7m KB/s)-Read error at byte 163600832mp 220637379 (Connection timed out). Retrying.--2015-12-30 17-58 try 16-(try: 2) http://212.187.212.74/bt/ab301ea7ea245c12ea9babf5235d75b04890bbd4/data/ArchLinuxARM-2014.10-rpi-rootfs.tar.gzConnecting to 212.187.212.74-80. Connected.HTTP request sent, awaiting response... Partial ContentLength: 220637379 (210m), 57036547 (54m) remaining [application/x-gzip] Saving to: `ArchLinuxARM-2014.10-rpi-rootfs.tar.gz'100% [+ = = >] 220637379 837K/s in 79s2015-12-30 17:59:36 (703KB/s)-`ArchLinuxARM-2014.10-rpi-rootfs.tar.gz' saved [2206379KB/s 220637379] pi@rpi ~ / notebooks $

Regenerate into an image and run the / bin/bash command, which is equivalent to creating a container

Pi@rpi ~ / notebooks $cat ArchLinuxARM-2014.10-rpi-rootfs.tar.gz | sudo docker import-archlinux46b927e18f3bb69337c58ae1e195f34eea7b17d0c71ef5dad63d6cbce102f844pi@rpi ~ / notebooks $sudo docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEarchlinux latest 46b927e18f3b 5 minutes ago 445.6 MBraring latest e0168fc30ed0 About an hour ago 0 Balpine 3.3.0 0a0aa665bfa2 2 hours ago 85.02 MBubuntu 14.04 723d8ba23c53 4 hours ago 204.8 MBpi@rpi ~ / notebooks $sudo docker run-ti archlinux / bin/bash [root@d7e0d53e291c /] # lsbin boot dev etc home lib mnt opt proc root run sbin srv sys tmp usr var [root@d7e0d53e291c /] #

Look at the print information in the background:

[info] POST / v1.15/containers/create [254b957f] + job create () [254b957f] + job log (create, d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37, archlinux:latest) [254b957f]-job log (create, d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37 Archlinux:latest) = OK (0) [254b957f]-job create () = OK (0) [info] POST / v1.15/containers/d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37/attach?stderr=1&stdin=1&stdout=1&stream=1 [254b957f] + job container_inspect (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) [254b957f]-job container_inspect (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) = OK (0) [254b957f] + job attach (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) [info] POST / v1.15/containers/d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37/start [254b957f] + job start (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) [254b957f] + job allocate_interface (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) [254b957f]-job allocate_ Interface (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) = OK (0) [254b957f] + job log (start D7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37, archlinux:latest) [254b957f]-job log (start, d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37, archlinux:latest) = OK (0) [254b957f]-job start (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37) = OK (0) [info] POST / v1.15/containers/d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37/resize?h=47&w=151 [254b957f] + job resize (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37, 47,151) [254b957f]-job resize (d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37, 47151) = OK (0) [info] GET / v1.15/containers/json?all=1 [254b957f] + job containers () [254b957f]-job containers () = OK (0)

Take a look at the system disk usage:

Pi@rpi / $dfcWARNING: / var/lib/docker/devicemapper was skipped because it cannot be stated: Permission deniedFILESYSTEM (=) USED FREE (-)% USED AVAILABLE TOTAL MOUNTED ON/dev/root [=] 64% 10.7G 29.6G / devtmpfs [-] 0% 458.7M 458.7M / devtmpfs [= -] 0% 92.3M 92.6M / runtmpfs [= -] 0% 5.0M 5.0M / run/locktmpfs [-] 0% 185 .2M 185.2M / run/shm/dev/mmcblk0p1 [= -] 36% 36.1M 55.9M / boottmpfs [-] 0% 100.0M / tmpcgroup [-] 0% 12.0K 12.0K / sys/fs/cgroupcgmfs [-] 0% 100.0K / run/cgmanager/fstmpfs [-] 0% 92.6M 92.6M / run/user/1000pi@rpi / $dfcWARNING: / var/lib/docker/devicemapper was skipped because It cannot be stated: Permission deniedFILESYSTEM (=) USED FREE (-)% USED AVAILABLE TOTAL MOUNTED ON/dev/root [= -] 59% 12.2G 29.6G / devtmpfs [-] 0% 458.7M 458.7M / devtmpfs [=- -] 0% 92.3M 92.6M / runtmpfs [= -] 0% 5.0M 5.0M / run/locktmpfs [-] 0% 185.2M / run/shm/dev/mmcblk0p1 [=- -] 36% 36.1M 55.9M / boottmpfs [-] 0% 100.0M 100.0M / tmpcgroup [-] 0% 12.0K 12.0K / sys/fs/cgroupcgmfs [- -] 0% 100.0K 100.0K / run/cgmanager/fstmpfs [-] 0% 92.6M 92.6M / run/user/1000pi@rpi / $dfcWARNING: / var/lib/docker/devicemapper was skipped because it cannot be stated: Permission deniedWARNING: / var/lib/docker/devicemapper/ Mnt/d7e0d53e291c9d8bf149588313439cedc49bf8c00f9c4095cb6fc5ef6ecd2c37 was skipped because it cannot be stated: Permission deniedFILESYSTEM (=) USED FREE (-)% USED AVAILABLE TOTAL MOUNTED ON/dev/root [= -] 61% 11.4G 29.6G / devtmpfs [-] 0% 458.7M 458.7M / devtmpfs [=- -] 0% 92.3M 92.6M / runtmpfs [= -] 0% 5.0M 5.0M / run/locktmpfs [-] 0% 185.2M 185.2M / run/shm/dev/ Mmcblk0p1 [= -] 36% 36.1M 55.9M / boottmpfs [-] 0% 100.0M 100.0M / tmpcgroup [-] 0% 12.0K 12.0K / sys/fs/cgroupcgmfs [-] 0% 100.0K 100.0K / run/cgmanager/fstmpfs [-] 0% 92.6M 92.6M / run/user/1000pi@rpi / $

After all, our mirror image is relatively large, and we slowly lose weight behind.

With the docker container, we can later experiment with another cluster swarm on raspberry pie.

This is all about how to create your own Docker image on raspberry pie 2. I hope the above content can be of some help and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report