From fa81c44ccb8c09d1c72d1d5c812f2803d134f015 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 19 Jun 2015 17:11:57 -0400 Subject: [PATCH 1/4] Put short labels on a single line Make building an image slightly faster by putting shorter label definitions on a single line. --- spcContainers.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spcContainers.md b/spcContainers.md index e913622..26a9211 100644 --- a/spcContainers.md +++ b/spcContainers.md @@ -439,8 +439,7 @@ RUN yum-config-manager --disable \* RUN yum-config-manager --enable rhel-7-server-rpms RUN yum -y update; yum -y install httpd; yum clean all; systemctl enable httpd -LABEL Version=1.0 -LABEL Vendor="Red Hat" License=GPLv3 +LABEL Version=1.0 Vendor="Red Hat" License=GPLv3 LABEL INSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e LOGDIR=${LOGDIR} -e CONFDIR=${CONFDIR} -e DATADIR=${DATADIR} -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/install.sh" LABEL UNINSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/uninstall.sh" From 3d0716fecee03ecfeac4efe192556bb4a0714146 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 19 Jun 2015 17:12:31 -0400 Subject: [PATCH 2/4] Fix a typo --- spcContainers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spcContainers.md b/spcContainers.md index 26a9211..6749ead 100644 --- a/spcContainers.md +++ b/spcContainers.md @@ -480,7 +480,7 @@ chroot ${HOST} /usr/bin/docker create -v /var/log/${NAME}/httpd:/var/log/httpd:Z # Install systemd unit file for running container sed -e "s/TEMPLATE/${NAME}/g" /etc/systemd/system/httpd_template.service > ${HOST}/etc/systemd/system/httpd_${NAME}.service -# Enabled systemd unit file +# Enable systemd unit file chroot ${HOST} /usr/bin/systemctl enable httpd_${NAME}.service ``` From ccf966383044fb4b3d2d31009732af84e653ffa7 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 19 Jun 2015 17:14:22 -0400 Subject: [PATCH 3/4] Escape environment references in LABEL statements Since 6784a772baaa20936f00b8adc00a4b4444356181 or so, environment variable values have been evaluated as part of processing LABEL statements at build-time. Since we want to preserve these for when the "atomic" command runs them, escape them. --- spcContainers.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spcContainers.md b/spcContainers.md index 6749ead..d8ef567 100644 --- a/spcContainers.md +++ b/spcContainers.md @@ -440,10 +440,10 @@ RUN yum-config-manager --enable rhel-7-server-rpms RUN yum -y update; yum -y install httpd; yum clean all; systemctl enable httpd LABEL Version=1.0 Vendor="Red Hat" License=GPLv3 -LABEL INSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e LOGDIR=${LOGDIR} -e CONFDIR=${CONFDIR} -e DATADIR=${DATADIR} -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/install.sh" -LABEL UNINSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/uninstall.sh" -LABEL RUN="docker run -dt -p 80 -v /sys/fs/cgroup:/sys/fs/cgroup httpd" +LABEL INSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e LOGDIR=\${LOGDIR} -e CONFDIR=\${CONFDIR} -e DATADIR=\${DATADIR} -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/install.sh" +LABEL UNINSTALL="docker run --rm --privileged -v /:/host -e HOST=/host -e IMAGE=IMAGE -e NAME=NAME IMAGE /usr/bin/uninstall.sh" +LABEL RUN="docker run -dt -p 80 -v /sys/fs/cgroup:/sys/fs/cgroup IMAGE" ADD root / From 88fef1f0149173f3d2523bc1e762e95c3aca6ba8 Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Fri, 19 Jun 2015 17:15:52 -0400 Subject: [PATCH 4/4] Mount the cgroups in the installed container When we're installing a container, add the cgroups hierarchy to the list of volumes it'll need, since we're using systemd's init as the container entry point. --- spcContainers.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spcContainers.md b/spcContainers.md index d8ef567..fa794f9 100644 --- a/spcContainers.md +++ b/spcContainers.md @@ -475,7 +475,7 @@ mkdir -p ${HOST}/${CONFDIR} ${HOST}/${LOGDIR}/httpd ${HOST}/${DATADIR} cp -pR /etc/httpd ${HOST}/${CONFDIR} # Create Container -chroot ${HOST} /usr/bin/docker create -v /var/log/${NAME}/httpd:/var/log/httpd:Z -v /var/lib/${NAME}:/var/lib/httpd:Z --name ${NAME} ${IMAGE} +chroot ${HOST} /usr/bin/docker create -v /var/log/${NAME}/httpd:/var/log/httpd:Z -v /var/lib/${NAME}:/var/lib/httpd:Z -p 80 -v /sys/fs/cgroup:/sys/fs/cgroup --name ${NAME} ${IMAGE} # Install systemd unit file for running container sed -e "s/TEMPLATE/${NAME}/g" /etc/systemd/system/httpd_template.service > ${HOST}/etc/systemd/system/httpd_${NAME}.service