LoginSignup
5
5

More than 5 years have passed since last update.

CentOS 5.11 32bitイメージ作った

Last updated at Posted at 2015-02-06

参考

手順

  • まずCentOS5 i386をインストールしておく。

  • 必要なパッケージインストール

yum install -y epel-release xz
yum install -y febootstrap
  • 作業ディレクトリを作成
  • febootstrap
mkdir bootstrap appliance mnt
febootstrap --names yum -o bootstrap
febootstrap-supermin-helper \
 -u root \
 -g root \
 -f ext2 bootstrap/ i686 appliance/kernel appliance/initrd appliance/root
  • イメージファイル内で作業。yumが使えない状態なので使えるようにする。
mount -t ext2 -o loop appliance/root mnt
chroot mnt

  # yumがエラー吐いて死ぬので初期化
  rm /var/lib/rpm/*
  rm -rf /var/cache/yum
  rpm --initdb

  # インターネットに出るため
  echo "nameserver 8.8.8.8" > /etc/resolv.conf
  # $releasever が空なので指定する
  # gpg指定もしないと`rpm -qa`などの結果が空になる
  mv /etc/yum.repos.d/CentOS-Base.repo{,.org}
  cat > /etc/yum.repos.d/CentOS-Base.repo <<EOF
[base]
name=CentOS-5 - Base
mirrorlist=http://mirrorlist.centos.org/?release=5&arch=i386&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
EOF
  # パッケージインストール
  yum install -y \
    yum coreutils \
    vim-minimal \
    vixie-cron anacron \
    curl wget \
    centos-release

  # yum install epel-releaseで入らなかったので
  rpm -ivh http://ftp-srv2.kddilabs.jp/Linux/distributions/fedora/epel/5/i386/epel-release-5-4.noarch.rpm
  sed -i -e 's/enabled=1/enabled=0/g' /etc/yum.repos.d/epel.repo
  # 64bit環境でdockerを使うと$basearchにx86_64が入る問題対応
  for i in /etc/yum.repos.d/*;do sed -i -e 's/\$basearch/i386/g' $i;done
  # $basearch値がi386固定であり続けるために
  echo "exclude=centos-release epel-release" >> /etc/yum.conf

  # パッケージを最新に更新
  yum update
  # キャッシュ削除
  yum clean all
  # 元々なかったので消す
  rm /etc/resolv.conf
  # 元に戻す
  mv /etc/yum.repos.d/CentOS-Base.repo{.org,}

  exit
  • docker import用にxz圧縮
tar cf centos5.tar -C mnt .
xz -v centos5.tar

umount mnt
  • dockerhubに登録
cat centos5.tar.xz | docker import - tukiyo3/centos5-i386
docker push tukiyo3/centos5-i386

usage

docker run -it -d tukiyo3/centos5-i386 /sbin/init
docker exec -it <ContainerID> /bin/bash
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5