Create Debian7 docker image

Docker importでイメージの作成をしてみた。debian7のvm内で作業した

dockerインストール

debian7ではapt-get install docker.ioでインストールできなかった…

https://docs.docker.com/installation/debian/のDebian Wheezy/Stable 7.x (64-bit) の方法で入れた

vagrant@packer-debian-7:~/debian-wheezy$ sudo echo "deb http://http.debian.net/debian wheezy-backports main" >> /etc/apt/sources.list  
vagrant@packer-debian-7:~/debian-wheezy$ sudo apt-get update  
vagrant@packer-debian-7:~/debian-wheezy$ sudo apt-get install -t wheezy-backports linux-image-amd64  
vagrant@packer-debian-7:~/debian-wheezy$ curl -sSL https://get.docker.com/ | sh  

debian7のイメージ作成

debootstrapを入れる

vagrant@packer-debian-7:~$ sudo apt-get install -y debootstrap

debianのベースシステムをインストール

vagrant@packer-debian-7:~$ mkdir debian-wheezy  
vagrant@packer-debian-7:~$ sudo /usr/sbin/debootstrap wheezy ./debian-wheezy http://debian-mirror.sakura.ne.jp/debian/  

chrootしてベースシステム確認

vagrant@packer-debian-7:~$ sudo chroot debian-wheezy /bin/bash  
root@packer-debian-7:/# ls  
bin   dev  home  lib64  mnt  proc  run   selinux  sys  usr  
boot  etc  lib   media  opt  root  sbin  srv      tmp  var  

よさげ

これを元にdockerイメージを作成

vagrant@packer-debian-7:~$ cd debian-wheezy/  
vagrant@packer-debian-7:~/debian-wheezy$ sudo tar -c . | sudo docker import - debian-wheezy  
c16645f2b6f50162d70acab19c7cf7f9988787455fed388763b41de78ca078c8  

作成したイメージをdocker hubにアップロード

タグ追加

vagrant@packer-debian-7:~/debian-wheezy$ sudo docker tag c166 lorentzca/debian-wheezy-base:latest  
vagrant@packer-debian-7:~/debian-wheezy$ sudo docker images  
REPOSITORY                     TAG                 IMAGE ID            CREATED             VIRTUAL SIZE  
debian-wheezy                  latest              c16645f2b6f5        9 minutes ago       218.5 MB  
lorentzca/debian-wheezy-base   latest              c16645f2b6f5        9 minutes ago       218.5 MB  

docker hubにプッシュ

vagrant@packer-debian-7:~/debian-wheezy$ sudo docker push lorentzca/debian-wheezy-base:latest  

作成したイメージを使ってみる

新しくcoreosのvmを立ち上げて、使ってみる

検索するとちゃんとlorentzca/debian-wheezy-baseが表示されます。やったー!

core@localhost ~ $ docker search debian-wheezy-base  
NAME                            DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED  
ozzyjohnson/wheezy-cloudtools   (457.1 MB) - AWS CLI, GCE CLI and Ansible ...   1                    [OK]  
bcbcarl/openssh                 This is an OpenSSH image based on Debian W...   1                    [OK]  
wiltan/debian-wheezy-base                                                       0  
rgaidot/debian-wheezy-base      A basic Debian 7.2 (Wheezy) image, created...   0  
takeshi81/debian-wheezy-php     Debian wheezy based PHP repo.                   0                    [OK]  
opencpu/wheezy                  Development build of opencpu based on Debi...   0                    [OK]  
vandries/phpenv                 PHPenv Dockerfile for trusted automated Do...   0                    [OK]  
agend07/btsync                  like ctlc/btsync but based on debian:wheezy     0                    [OK]  
jasonswindle/docker-jre         OpenJRE 7 / 6 Docker-ized, based on google...   0                    [OK]  
kagami/nginx-hhvm               Personal maintained nginx-hhvm server base...   0                    [OK]  
hmtreasury/base                 A base Docker image that inherits from Deb...   0                    [OK]  
atlashealth/base                Docker image based on debian:wheezy with s...   0                    [OK]  
lorentzca/debian-wheezy-base                                                    0  
fiksn/debian-wheezy-base                                                        0  

イメージをダウンロード

core@localhost ~ $ docker pull lorentzca/debian-wheezy-base  
core@localhost ~ $ docker images  
REPOSITORY                     TAG                 IMAGE ID            CREATED             VIRTUAL SIZE  
lorentzca/debian-wheezy-base   latest              c16645f2b6f5        29 minutes ago      218.5 MB  

docker runしてみる

core@localhost ~ $ docker run lorentzca/debian-wheezy-base cat /etc/issue  
Debian GNU/Linux 7 \n \l  

やったー!

https://registry.hub.docker.com/u/lorentzca/debian-wheezy-base/