mirror of
https://github.com/p8952/bocker.git
synced 2025-11-10 19:24:01 +01:00
Install undocker & create a bocker image from busybox; Move unshare to /usr/bin
This commit is contained in:
parent
e4c19fdc55
commit
402e0912df
15
Vagrantfile
vendored
15
Vagrantfile
vendored
@ -1,16 +1,29 @@
|
|||||||
$script = <<SCRIPT
|
$script = <<SCRIPT
|
||||||
yum install -y autoconf automake btrfs-progs gettext-devel git libtool
|
(
|
||||||
|
rpm -i https://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
|
||||||
|
yum install -y -q autoconf automake btrfs-progs docker gettext-devel git libtool python-pip
|
||||||
|
|
||||||
fallocate -l 10G ~/btrfs.img
|
fallocate -l 10G ~/btrfs.img
|
||||||
mkdir /var/bocker
|
mkdir /var/bocker
|
||||||
mkfs.btrfs ~/btrfs.img
|
mkfs.btrfs ~/btrfs.img
|
||||||
mount -o loop ~/btrfs.img /var/bocker
|
mount -o loop ~/btrfs.img /var/bocker
|
||||||
|
|
||||||
|
pip install git+https://github.com/larsks/undocker
|
||||||
|
systemctl start docker.service
|
||||||
|
docker pull busybox
|
||||||
|
docker save busybox | undocker -o base-image
|
||||||
|
rm -rf /vagrant/base-image
|
||||||
|
mv base-image /vagrant || true
|
||||||
|
|
||||||
git clone https://github.com/karelzak/util-linux.git
|
git clone https://github.com/karelzak/util-linux.git
|
||||||
cd util-linux
|
cd util-linux
|
||||||
git checkout tags/v2.25.2
|
git checkout tags/v2.25.2
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
./configure --without-ncurses --without-python
|
./configure --without-ncurses --without-python
|
||||||
make
|
make
|
||||||
|
mv unshare /usr/bin/unshare
|
||||||
cd ..
|
cd ..
|
||||||
|
) 2>&1
|
||||||
SCRIPT
|
SCRIPT
|
||||||
|
|
||||||
Vagrant.configure(2) do |config|
|
Vagrant.configure(2) do |config|
|
||||||
|
|||||||
6
bocker
6
bocker
@ -3,7 +3,7 @@ set -o errexit -o nounset -o pipefail; shopt -s nullglob
|
|||||||
|
|
||||||
btrfs_path='/var/bocker';
|
btrfs_path='/var/bocker';
|
||||||
basename=$(which basename); btrfs=$(which btrfs); cat=$(which cat);
|
basename=$(which basename); btrfs=$(which btrfs); cat=$(which cat);
|
||||||
mount=$(which mount); umount=$(which umount); chroot=$(which chroot)
|
unshare=$(which unshare); umount=$(which umount); chroot=$(which chroot)
|
||||||
|
|
||||||
function CHECK_VOLUME() {
|
function CHECK_VOLUME() {
|
||||||
if $btrfs subvolume list "$btrfs_path" | grep -qw "$1"; then
|
if $btrfs subvolume list "$btrfs_path" | grep -qw "$1"; then
|
||||||
@ -50,8 +50,8 @@ CHECK_VOLUME "$1"
|
|||||||
uuid="ps_$(uuidgen)"
|
uuid="ps_$(uuidgen)"
|
||||||
$btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$uuid" > /dev/null
|
$btrfs subvolume snapshot "$btrfs_path/$1" "$btrfs_path/$uuid" > /dev/null
|
||||||
echo "$2" > "$btrfs_path/$uuid/$uuid.cmd"
|
echo "$2" > "$btrfs_path/$uuid/$uuid.cmd"
|
||||||
./util-linux/unshare -fp --mount-proc "$chroot" "$btrfs_path/$uuid" \
|
"$unshare" -fp --mount-proc "$chroot" "$btrfs_path/$uuid" \
|
||||||
/bin/bash -c "/bin/mount -t proc proc /proc && /bin/$2" \
|
/bin/sh -c "/bin/mount -t proc proc /proc && /bin/$2" \
|
||||||
2>&1 | tee "$btrfs_path/$uuid/$uuid.log"
|
2>&1 | tee "$btrfs_path/$uuid/$uuid.log"
|
||||||
$umount "$btrfs_path/$uuid/proc"
|
$umount "$btrfs_path/$uuid/proc"
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user