From 6a9beb4a33a0a44ba7ffbafc80d794604f030d57 Mon Sep 17 00:00:00 2001 From: Sam Yaple Date: Wed, 4 Nov 2015 02:32:11 +0000 Subject: [PATCH] Add Docker in Docker container Change-Id: I3c953125ed0105b7e8b62e62da56bf3fa30889d1 Partially-Implements: blueprint multinode-gate --- docker/dind/Dockerfile.j2 | 28 ++++++++++++++++++++++++++++ docker/dind/start.sh | 28 ++++++++++++++++++++++++++++ etc/kolla/kolla-build.conf | 2 +- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 docker/dind/Dockerfile.j2 create mode 100644 docker/dind/start.sh diff --git a/docker/dind/Dockerfile.j2 b/docker/dind/Dockerfile.j2 new file mode 100644 index 0000000000..e61196ac6b --- /dev/null +++ b/docker/dind/Dockerfile.j2 @@ -0,0 +1,28 @@ +FROM {{ namespace }}/{{ image_prefix }}openstack-base:{{ tag }} +MAINTAINER Kolla Project (https://launchpad.net/kolla) + +{% if base_distro in ['centos', 'fedora', 'oraclelinux', 'rhel'] %} + +# Since the gate cannot do DinD on centos due to the age of the kernel, we don't +# build a true DinD image. Should the time come that we get a newer kernel in +# the centos gate and we want to do multinode we can populate this container +RUN /bin/true + +{% elif base_distro in ['ubuntu', 'debian'] %} + +RUN echo 'deb http://apt.dockerproject.org/repo ubuntu-trusty main' > /etc/apt/sources.list.d/docker.list \ + && apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D \ + && apt-get update \ + && apt-get install -y --no-install-recommends \ + btrfs-tools \ + docker-engine=1.8.2-0~trusty \ + openssh-server \ + && apt-get clean \ + && pip --no-cache-dir install docker-py + +{% endif %} + +COPY start.sh /usr/local/bin/kolla_start +RUN chmod 755 /usr/local/bin/kolla_start + +{{ include_footer }} diff --git a/docker/dind/start.sh b/docker/dind/start.sh new file mode 100644 index 0000000000..61a4b09e9d --- /dev/null +++ b/docker/dind/start.sh @@ -0,0 +1,28 @@ +#!/bin/bash + +set -o errexit +set -o nounset + +# External processes will be occuring and we must wait for them +while [[ ! -e "/kolla_dind_ready" ]]; do + sleep 1 +done + +docker daemon -s btrfs 2>&1 > docker.log & +docker_pid=$! + +mkdir /var/run/sshd +/usr/sbin/sshd -D 2>&1 > sshd.log & +sshd_pid=$! + +mkdir -p /root/.ssh/ +echo "${SSH_PUB}" > /root/.ssh/authorized_keys + +# Wait for docker daemon +sleep 5 + +# Due to a quirk in the cloning method we end up with a bunch of dead containers +docker rm -v -f $(docker ps -a --no-trunc -q) + +# Wait until child processes exit (they should never exit) +wait diff --git a/etc/kolla/kolla-build.conf b/etc/kolla/kolla-build.conf index 75a102887f..d2fc2e5519 100644 --- a/etc/kolla/kolla-build.conf +++ b/etc/kolla/kolla-build.conf @@ -52,7 +52,7 @@ infra = ceph,data,mariadb,haproxy,keepalived,kolla-ansible,memcached,mongodb,ope main = cinder,ceilometer,glance,heat,horizon,keystone,neutron,nova,swift aux = designate,gnocchi,ironic,magnum,zaqar default = data,kolla-ansible,glance,haproxy,heat,horizon,keepalived,keystone,memcached,mariadb,neutron,nova,openvswitch,rabbitmq,rsyslog -gate = ceph,cinder,data,glance,haproxy,heat,horizon,keepalived,keystone,kolla-ansible,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,rsyslog +gate = ceph,cinder,data,dind,glance,haproxy,heat,horizon,keepalived,keystone,kolla-ansible,mariadb,memcached,neutron,nova,openvswitch,rabbitmq,rsyslog # Provide location of sources for source install builds. # Example: