Created
July 3, 2015 14:07
-
-
Save ViktorOgnev/7e6c48d88771e22ad316 to your computer and use it in GitHub Desktop.
build 32bit-ubuntu docker images, run this script on trusty or newer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -ex | |
### Build a docker image for ubuntu i386. | |
### settings | |
arch=i386 | |
suite=${1:-trusty} | |
chroot_dir="/var/chroot/$suite" | |
mkdir -p $chroot_dir | |
mkdir -p $chroot_dir/etc | |
mkdir -p $chroot_dir/etc/apt | |
mkdir -p $chroot_dir/proc | |
apt_mirror='http://archive.ubuntu.com/ubuntu' | |
docker_image="32bit/ubuntu:${1:-14.04}" | |
### make sure that the required tools are installed | |
apt-get update | |
apt-get install -y docker.io docker debootstrap dchroot | |
### install a minbase system with debootstrap | |
export DEBIAN_FRONTEND=noninteractive | |
debootstrap --variant=minbase --arch=$arch $suite $chroot_dir $apt_mirror | |
### update the list of package sources | |
cat <<EOF > $chroot_dir/etc/apt/sources.list | |
deb $apt_mirror $suite main restricted universe multiverse | |
deb $apt_mirror $suite-updates main restricted universe multiverse | |
deb $apt_mirror $suite-backports main restricted universe multiverse | |
deb http://security.ubuntu.com/ubuntu $suite-security main restricted universe multiverse | |
deb http://extras.ubuntu.com/ubuntu $suite main | |
EOF | |
### install ubuntu-minimal | |
cp /etc/resolv.conf $chroot_dir/etc/resolv.conf | |
mount -o bind /proc $chroot_dir/proc | |
chroot $chroot_dir apt-get update | |
chroot $chroot_dir apt-get -y upgrade | |
chroot $chroot_dir apt-get -y install ubuntu-minimal | |
### cleanup and unmount /proc | |
chroot $chroot_dir apt-get autoclean | |
chroot $chroot_dir apt-get clean | |
chroot $chroot_dir apt-get autoremove | |
rm $chroot_dir/etc/resolv.conf | |
umount $chroot_dir/proc | |
### create a tar archive from the chroot directory | |
tar cfz ubuntu.tgz -C $chroot_dir . | |
### import this tar archive into a docker image: | |
cat ubuntu.tgz | docker import - $docker_image | |
# ### push image to Docker Hub | |
# docker push $docker_image | |
### cleanup | |
rm ubuntu.tgz | |
rm -rf $chroot_dir |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment