blob: 4fa23864fb33899ba0c7346f00055bb3e461ac8b [file] [log] [blame]
Dean Troyer2aa2a892013-08-04 19:53:19 -05001#!/usr/bin/env bash
2
3# **install_docker.sh** - Do the initial Docker installation and configuration
4
5# install_docker.sh
6#
7# Install docker package and images
8# * downloads a base busybox image and a glance registry image if necessary
9# * install the images in Docker's image cache
10
11
12# Keep track of the current directory
13SCRIPT_DIR=$(cd $(dirname "$0") && pwd)
14TOP_DIR=$(cd $SCRIPT_DIR/../..; pwd)
15
16# Import common functions
17source $TOP_DIR/functions
18
19# Load local configuration
20source $TOP_DIR/stackrc
21
22FILES=$TOP_DIR/files
23
24# Get our defaults
25source $TOP_DIR/lib/nova_plugins/hypervisor-docker
26
27SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
28
29
30# Install Docker Service
31# ======================
32
33# Stop the auto-repo updates and do it when required here
34NO_UPDATE_REPOS=True
35
36# Set up home repo
37curl https://get.docker.io/gpg | sudo apt-key add -
38install_package python-software-properties && \
39 sudo sh -c "echo deb $DOCKER_APT_REPO docker main > /etc/apt/sources.list.d/docker.list"
40apt_get update
Sam Alba5a77d032013-10-21 16:17:30 -070041install_package --force-yes lxc-docker socat
Dean Troyer2aa2a892013-08-04 19:53:19 -050042
43# Start the daemon - restart just in case the package ever auto-starts...
44restart_service docker
45
46echo "Waiting for docker daemon to start..."
47DOCKER_GROUP=$(groups | cut -d' ' -f1)
DennyZhangca1b8522013-11-17 15:44:32 -060048CONFIGURE_CMD="while ! /bin/echo -e 'GET /v1.3/version HTTP/1.0\n\n' | socat - unix-connect:$DOCKER_UNIX_SOCKET 2>/dev/null | grep -q '200 OK'; do
Dean Troyer2aa2a892013-08-04 19:53:19 -050049 # Set the right group on docker unix socket before retrying
50 sudo chgrp $DOCKER_GROUP $DOCKER_UNIX_SOCKET
51 sudo chmod g+rw $DOCKER_UNIX_SOCKET
52 sleep 1
53done"
54if ! timeout $SERVICE_TIMEOUT sh -c "$CONFIGURE_CMD"; then
55 die $LINENO "docker did not start"
56fi
57
Eric Windisch2dac8852014-01-31 01:25:28 -050058# Get guest container image
59docker pull $DOCKER_IMAGE
60docker tag $DOCKER_IMAGE $DOCKER_IMAGE_NAME
Dean Troyer2aa2a892013-08-04 19:53:19 -050061
Eric Windisch2dac8852014-01-31 01:25:28 -050062# Get docker-registry image
63docker pull $REGISTRY_IMAGE
64docker tag $REGISTRY_IMAGE $REGISTRY_IMAGE_NAME