User Tools

Site Tools


doc:howto:docker_openwrt_image

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
doc:howto:docker_openwrt_image [2014/02/14 16:41]
zoobab2
doc:howto:docker_openwrt_image [2014/05/06 18:18] (current)
nodeguy Import the root file system directly preserving original /dev entries.
Line 5: Line 5:
 {{:​media:​homepage-docker-logo.png|}} {{:​media:​homepage-docker-logo.png|}}
  
-Download first the x86 image (there should an x64 image in trunk):+Import ​the base image:
  
 <​code>​ <​code>​
-root@turmes /​home/​zoobab/​docker ​[9]# wget http://​downloads.openwrt.org/​attitude_adjustment/​12.09-rc2/​x86/​generic/​openwrt-x86-generic-rootfs.tar.gz +docker ​import ​http://​downloads.openwrt.org/​attitude_adjustment/​12.09/​x86/​generic/​openwrt-x86-generic-rootfs.tar.gz openwrt-x86-generic-rootfs 
---2014-02-13 00:​27:​19-- ​ http://​downloads.openwrt.org/​attitude_adjustment/​12.09-rc2/​x86/​generic/​openwrt-x86-generic-rootfs.tar.gz +docker images 
-Resolving downloads.openwrt.org... 78.24.191.177 +REPOSITORY ​                          ​TAG                   IMAGE ID            CREATED ​            VIRTUAL ​SIZE 
-Connecting to downloads.openwrt.org|78.24.191.177|:​80... connected. +openwrt-x86-generic-rootfs ​          latest ​               ​2cebd16f086c ​       ​6 ​minutes ​ago       5.283 MB
-HTTP request sent, awaiting response... 200 OK +
-Length: 2221396 (2.1M) [application/​octet-stream] +
-Saving to: ‘openwrt-x86-generic-rootfs.tar.gz’ +
- +
-100%[==========================================================================================================================================================================>​] 2,​221,​396 ​  ​1.26MB/​s ​  in 1.7s    +
- +
-2014-02-13 00:27:21 (1.26 MB/s) - ‘openwrt-x86-generic-rootfs.tar.gz’ saved [2221396/​2221396] +
-</​code>​ +
- +
-Then import the rootfs.tar.gz into docker via zcat: +
- +
-<​code>​ +
-root@turmes /​home/​zoobab/​docker [10]# zcat openwrt-x86-generic-rootfs.tar.gz | docker import - openwrt-x86 +
-5f284db5c31d +
-root@turmes /​home/​zoobab/​docker [11]# docker images +
-REPOSITORY ​         TAG                 ​ID                  CREATED ​            ​SIZE +
-openwrt-x86 ​        ​latest ​             ​5f284db5c31d ​       ​6 ​seconds ​ago       5.705 MB (virtual 5.705 MB) +
-busybox ​            ​latest ​             e9aa60c60128 ​       10 months ago       6.825 MB (virtual 6.825 MB)+
 </​code>​ </​code>​
  
Line 35: Line 17:
  
 <​code>​ <​code>​
-root@turmes /​home/​zoobab/​docker [14]# docker run -i openwrt-x86 cat /etc/banner+root@turmes /​home/​zoobab/​docker [14]# docker run -i openwrt-x86-generic-rootfs ​cat /etc/banner
   _______ ​                    ​________ ​       __   _______ ​                    ​________ ​       __
  ​| ​      ​|.-----.-----.-----.| ​ |  |  |.----.| ​ |_  ​| ​      ​|.-----.-----.-----.| ​ |  |  |.----.| ​ |_
Line 53: Line 35:
  ​-----------------------------------------------------  ​-----------------------------------------------------
 root@turmes /​home/​zoobab/​docker [15]#  root@turmes /​home/​zoobab/​docker [15]# 
-</​code>​ 
- 
-Now starting /sbin/init is more problematic:​ 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker [15]# docker run -i openwrt-x86 /sbin/init 
-init started: BusyBox v1.19.4 (2013-03-06 20:07:44 UTC) 
-sysinit: date: can't set kernel time zone: Operation not permitted 
- 
-sysinit: Loading defaults 
- 
-sysinit: Loading synflood protection 
- 
-sysinit: Adding custom chains 
- 
-sysinit: Loading zones 
- 
-sysinit: Loading forwardings 
- 
-sysinit: Loading rules 
- 
-sysinit: Loading redirects 
- 
-sysinit: Loading includes 
- 
-sysinit: Optimizing conntrack 
- 
-sysinit: Loading interfaces 
- 
-sysinit: dnsmasq: failed to seed the random number generator: No such file or directory 
-</​code>​ 
- 
-It seems the needed /dev entries are not present: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab [7]# docker run -i openwrt-x86 busybox ls /dev 
-kmsg 
-ptmx 
-pts 
-shm 
-</​code>​ 
- 
-So let's create them in the tar.gz archive: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker [13]# mkdir -pv workdir 
-mkdir: created directory ‘workdir’ 
-root@turmes /​home/​zoobab/​docker [14]# l 
-total 4348 
--rw-r--r-- 1 root root 2221396 Apr 11  2013 openwrt-x86-generic-rootfs.tar.gz 
-drwxr-xr-x 2 root root    4096 Feb 13 22:04 workdir 
-root@turmes /​home/​zoobab/​docker [15]# tar -xzf openwrt-x86-generic-rootfs.tar.gz -C workdir/ 
-</​code>​ 
- 
-Dev directory is empty: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker [17]# cd workdir/ 
-root@turmes /​home/​zoobab/​docker/​workdir [18]# l 
-total 56 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 bin 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 dev 
-drwxr-xr-x 13 root root 4096 Mar 23  2013 etc 
-drwxr-xr-x 14 root root 4096 Mar 23  2013 lib 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 mnt 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 overlay 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 proc 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 rom 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 root 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 sbin 
-drwxr-xr-x ​ 2 root root 4096 Mar 23  2013 sys 
-drwxrwxrwt ​ 2 root root 4096 Mar 23  2013 tmp 
-drwxr-xr-x ​ 6 root root 4096 Mar 23  2013 usr 
-lrwxrwxrwx ​ 1 root root    4 Mar 23  2013 var -> /tmp 
-drwxr-xr-x ​ 4 root root 4096 Mar 23  2013 www 
-root@turmes /​home/​zoobab/​docker/​workdir [19]# cd dev/ 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [20]# l 
-total 0 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [21]#  
-</​code>​ 
- 
-Let's create the entries: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [22]# mknod -m 622 console c 5 1 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [23]# mknod -m 666 null c 1 3 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [24]# mknod -m 666 zero c 1 5 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [25]# mknod -m 666 tty c 5 0 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [26]# mknod -m 444 random c 1 8 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [27]# mknod -m 444 urandom c 1 9 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [28]# ls -al 
-total 8 
-drwxr-xr-x ​ 2 root root 4096 Feb 13 22:11 . 
-drwxr-xr-x 16 root root 4096 Mar 23  2013 .. 
-crw--w--w- ​ 1 root root 5, 1 Feb 13 22:10 console 
-crw-rw-rw- ​ 1 root root 1, 3 Feb 13 22:10 null 
-cr--r--r-- ​ 1 root root 1, 8 Feb 13 22:10 random 
-crw-rw-rw- ​ 1 root root 5, 0 Feb 13 22:10 tty 
-cr--r--r-- ​ 1 root root 1, 9 Feb 13 22:11 urandom 
-crw-rw-rw- ​ 1 root root 1, 5 Feb 13 22:10 zero 
-</​code>​ 
- 
-Now let's make a tar.gz: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker/​workdir/​dev [29]# cd .. 
-root@turmes /​home/​zoobab/​docker/​workdir [30]# tar -czf ../​openwrt-x86-generic-rootfs+deventries.tar.gz . 
-root@turmes /​home/​zoobab/​docker/​workdir [31]# cd .. 
-root@turmes /​home/​zoobab/​docker [44]# ls -al 
-total 4356 
-drwxr-xr-x ​ 3 root   ​root ​     4096 Feb 13 22:16 . 
-drwx------ 36 zoobab zoobab ​   4096 Feb 13 21:20 .. 
--rw-r--r-- ​ 1 root   ​root ​  ​2222094 Feb 13 22:16 openwrt-x86-generic-rootfs+deventries.tar.gz 
--rw-r--r-- ​ 1 root   ​root ​  ​2221396 Apr 11  2013 openwrt-x86-generic-rootfs.tar.gz 
-drwxr-xr-x 16 root   ​root ​     4096 Mar 23  2013 workdir 
-</​code>​ 
- 
-Now we can import this to docker: 
- 
-<​code>​ 
-root@turmes /​home/​zoobab/​docker [47]# zcat openwrt-x86-generic-rootfs+deventries.tar.gz | docker import - openwrt-x86-generic-rootfs+deventries 
-b9daeeb9a878 
-root@turmes /​home/​zoobab/​docker [48]# docker images 
-REPOSITORY ​                              ​TAG ​                ​ID ​                 CREATED ​            SIZE 
-openwrt-x86-generic-rootfs+deventries ​   latest ​             b9daeeb9a878 ​       2 seconds ago       5.705 MB (virtual 5.705 MB) 
 </​code>​ </​code>​
  
Line 183: Line 40:
  
 <​code>​ <​code>​
-root@turmes /​home/​zoobab [17]# docker run -i openwrt-x86-generic-rootfs+deventries ​ifconfig+root@turmes /​home/​zoobab [17]# docker run -i openwrt-x86-generic-rootfs ifconfig
 eth0      Link encap:​Ethernet ​ HWaddr F2:​06:​70:​1D:​D0:​65  ​ eth0      Link encap:​Ethernet ​ HWaddr F2:​06:​70:​1D:​D0:​65  ​
           inet addr:​172.17.0.30 ​ Bcast:​172.17.255.255 ​ Mask:​255.255.0.0           inet addr:​172.17.0.30 ​ Bcast:​172.17.255.255 ​ Mask:​255.255.0.0
Line 202: Line 59:
           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)           RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
  
-root@turmes /​home/​zoobab [18]# docker run -i openwrt-x86-generic-rootfs+deventries ​/sbin/init+root@turmes /​home/​zoobab [18]# docker run -i openwrt-x86-generic-rootfs /sbin/init
 init started: BusyBox v1.19.4 (2013-03-06 20:07:44 UTC) init started: BusyBox v1.19.4 (2013-03-06 20:07:44 UTC)
 sysinit: date: can't set kernel time zone: Operation not permitted sysinit: date: can't set kernel time zone: Operation not permitted
Line 232: Line 89:
  
 <​code>​ <​code>​
-root@turmes /​home/​zoobab [20]# docker run -i -t openwrt-x86-generic-rootfs+deventries ​/bin/ash+root@turmes /​home/​zoobab [20]# docker run -i -t openwrt-x86-generic-rootfs /bin/ash
  
  
doc/howto/docker_openwrt_image.1392392506.txt.bz2 · Last modified: 2014/02/14 16:41 by zoobab2