Created
October 15, 2018 08:16
-
-
Save AkihiroSuda/772604c6895d5ced5357e5dcc154be22 to your computer and use it in GitHub Desktop.
Create nightly Docker-in-LXD environment
This file contains 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 | |
# Create Docker-in-LXD environment | |
set -exu -o pipefail | |
if [[ $# -ne 1 ]]; then | |
echo "Usage: $0 NAME" | |
exit 1 | |
fi | |
CONTAINER=$1 | |
POOL=pool-dir | |
IMAGE=ubuntu:18.04 | |
# Create pool if not created yet | |
# We use "dir" driver. /var/lib/lxd/storage-pools on the host needs to be ext4 or xfs. | |
lxc storage show $POOL > /dev/null 2>&1 || lxc storage create $POOL dir | |
# Remove existing container if any | |
lxc info $CONTAINER > /dev/null 2>&1 && lxc rm -f $CONTAINER | |
# Create container | |
lxc launch $IMAGE $CONTAINER -s $POOL -c security.nesting=true | |
# Cargo-cult sleep for networking (FIXME) | |
sleep 10 | |
# Execute the script | |
cat <<EOF | lxc exec $CONTAINER -- sh -exu | |
for f in dockerd containerd containerd-shim ctr runc docker-init docker-proxy docker;do | |
curl -o /usr/bin/\$f https://master.dockerproject.org/linux/x86_64/\$f | |
chmod +x /usr/bin/\$f | |
done | |
groupadd docker | |
for f in docker.socket docker.service; do | |
curl -o /lib/systemd/system/\$f https://raw.githubusercontent.com/moby/moby/master/contrib/init/systemd/\$f | |
done | |
systemctl daemon-reload | |
systemctl enable docker | |
systemctl start docker | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment