Created
June 18, 2014 11:40
-
-
Save bashtoni/633b33e9441d0a5a3249 to your computer and use it in GitHub Desktop.
Script to create CentOS 7 docker image
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 -e | |
# Script to build a base CentOS 7 Pre-release docker image | |
# Tested under CentOS 6 | |
BUILDROOT="/centos7" | |
if [ $(id -u) -ne 0 ]; then | |
echo "Must be run as root" | |
exit 1 | |
fi | |
test -f /bin/tar || yum -y install tar | |
mkdir $BUILDROOT | |
rpm --root=$BUILDROOT --initdb | |
rpm --root=$BUILDROOT -ivh http://buildlogs.centos.org/centos/7/os/x86_64-20140617/Packages/centos-release-7-0.el7.0.140617.3.x86_64.rpm | |
# yum config not included in the release package yet | |
cp /etc/yum.conf ${BUILDROOT}/etc/yum.conf | |
mkdir -p ${BUILDROOT}/etc/yum.repos.d | |
cat <<HERE > ${BUILDROOT}/etc/yum.repos.d/centos7qa.repo | |
[base] | |
name=CentOS7QA | |
baseurl=http://buildlogs.centos.org/centos/7/os/x86_64-20140617/ | |
gpgcheck=0 | |
HERE | |
mkdir ${BUILDROOT}/dev | |
mknod -m 600 ${BUILDROOT}/dev/console c 5 1 | |
mknod -m 600 ${BUILDROOT}/dev/initctl p | |
mknod -m 666 ${BUILDROOT}/dev/full c 1 7 | |
mknod -m 666 ${BUILDROOT}/dev/null c 1 3 | |
mknod -m 666 ${BUILDROOT}/dev/ptmx c 5 2 | |
mknod -m 666 ${BUILDROOT}/dev/random c 1 8 | |
mknod -m 666 ${BUILDROOT}/dev/tty c 5 0 | |
mknod -m 666 ${BUILDROOT}/dev/tty0 c 4 0 | |
mknod -m 666 ${BUILDROOT}/dev/urandom c 1 9 | |
mknod -m 666 ${BUILDROOT}/dev/zero c 1 5 | |
yum --installroot=$BUILDROOT --setopt=tsflags=nodocs \ | |
--setopt=group_package_types=mandatory -y groupinstall Core | |
yum --installroot=$BUILDROOT -y clean all | |
cat > ${BUILDROOT}/etc/sysconfig/network <<EOF | |
NETWORKING=yes | |
HOSTNAME=localhost.localdomain | |
EOF | |
rm -rf ${BUILDROOT}/usr/{{lib,share}/locale,{lib,lib64}/gconv,bin/localedef,sbin/build-locale-archive} | |
# docs | |
rm -rf ${BUILDROOT}/usr/share/{man,doc,info,gnome/help} | |
# cracklib | |
rm -rf ${BUILDROOT}/usr/share/cracklib | |
# i18n | |
rm -rf ${BUILDROOT}/usr/share/i18n | |
# sln | |
rm -rf ${BUILDROOT}/sbin/sln | |
# ldconfig | |
rm -rf ${BUILDROOT}/etc/ld.so.cache | |
rm -rf ${BUILDROOT}/var/cache/ldconfig/* | |
tar --numeric-owner -f /vagrant/centos7qa.tar -C $BUILDROOT . |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment