From 5af87d147580555c72e6a1d448ab663f991cc737 Mon Sep 17 00:00:00 2001 From: Daniel Mizyrycki Date: Tue, 5 Nov 2013 13:21:25 -0800 Subject: [PATCH] contrib: Desktop integration. Firefox usecase. --- contrib/desktop-integration/README.txt | 11 +++++ contrib/desktop-integration/data/Dockerfile | 38 ++++++++++++++ .../desktop-integration/firefox/Dockerfile | 49 +++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 contrib/desktop-integration/README.txt create mode 100644 contrib/desktop-integration/data/Dockerfile create mode 100644 contrib/desktop-integration/firefox/Dockerfile diff --git a/contrib/desktop-integration/README.txt b/contrib/desktop-integration/README.txt new file mode 100644 index 0000000000..2f55c979e3 --- /dev/null +++ b/contrib/desktop-integration/README.txt @@ -0,0 +1,11 @@ +Desktop Integration +=================== + +The ./contrib/desktop-integration contains examples of typical dockerized +desktop applications. + +Examples +======== + +* Data container: ./data/Dockerfile creates a data image sharing /data volume +* Firefox: ./firefox/Dockerfile shows a way to dockerize a common multimedia application diff --git a/contrib/desktop-integration/data/Dockerfile b/contrib/desktop-integration/data/Dockerfile new file mode 100644 index 0000000000..453afdd3d6 --- /dev/null +++ b/contrib/desktop-integration/data/Dockerfile @@ -0,0 +1,38 @@ +# VERSION: 0.1 +# DESCRIPTION: Create data image sharing /data volume +# AUTHOR: Daniel Mizyrycki +# COMMENTS: +# This image is used as base for all data containers. +# /data volume is owned by sysadmin. +# USAGE: +# # Download data Dockerfile +# wget http://raw.github.com/dotcloud/docker/master/contrib/desktop-integration/data/Dockerfile +# +# # Build data image +# docker build -t data -rm . +# +# # Create a data container. (eg: firefox-data) +# docker run -name firefox-data data true +# +# # List data from it +# docker run -volumes-from firefox-data busybox ls -al /data + +docker-version 0.6.5 + +# Smallest base image, just to launch a container +from busybox +maintainer Daniel Mizyrycki + +# Create a regular user +run echo 'sysadmin:x:1000:1000::/data:/bin/sh' >> /etc/passwd +run echo 'sysadmin:x:1000:' >> /etc/group + +# Create directory for that user +run mkdir /data +run chown sysadmin.sysadmin /data + +# Add content to /data. This will keep sysadmin ownership +run touch /data/init_volume + +# Create /data volume +VOLUME /data diff --git a/contrib/desktop-integration/firefox/Dockerfile b/contrib/desktop-integration/firefox/Dockerfile new file mode 100644 index 0000000000..f8924f4b4a --- /dev/null +++ b/contrib/desktop-integration/firefox/Dockerfile @@ -0,0 +1,49 @@ +# VERSION: 0.7 +# DESCRIPTION: Create firefox container with its dependencies +# AUTHOR: Daniel Mizyrycki +# COMMENTS: +# This file describes how to build a Firefox container with all +# dependencies installed. It uses native X11 unix socket and alsa +# sound devices. Tested on Debian 7.2 +# USAGE: +# # Download Firefox Dockerfile +# wget http://raw.github.com/dotcloud/docker/master/contrib/desktop-integration/firefox/Dockerfile +# +# # Build firefox image +# docker build -t firefox -rm . +# +# # Run stateful data-on-host firefox. For ephemeral, remove -v /data/firefox:/data +# docker run -v /data/firefox:/data -v /tmp/.X11-unix:/tmp/.X11-unix \ +# -v /dev/snd:/dev/snd -lxc-conf='lxc.cgroup.devices.allow = c 116:* rwm' \ +# -e DISPLAY=unix$DISPLAY firefox +# +# # To run stateful dockerized data containers +# docker run -volumes-from firefox-data -v /tmp/.X11-unix:/tmp/.X11-unix \ +# -v /dev/snd:/dev/snd -lxc-conf='lxc.cgroup.devices.allow = c 116:* rwm' \ +# -e DISPLAY=unix$DISPLAY firefox + +docker-version 0.6.5 + +# Base docker image +from tianon/debian:wheezy +maintainer Daniel Mizyrycki + +# Install firefox dependencies +run echo "deb http://ftp.debian.org/debian/ wheezy main contrib" > /etc/apt/sources.list +run apt-get update +run DEBIAN_FRONTEND=noninteractive apt-get install -y libXrender1 libasound2 \ + libdbus-glib-1-2 libgtk2.0-0 libpango1.0-0 libxt6 wget bzip2 sudo + +# Install Firefox +run mkdir /application +run cd /application; wget -O - \ + http://ftp.mozilla.org/pub/mozilla.org/firefox/releases/25.0/linux-x86_64/en-US/firefox-25.0.tar.bz2 | tar jx + +# create sysadmin account +run useradd -m -d /data -p saIVpsc0EVTwA sysadmin +run sed -Ei 's/sudo:x:27:/sudo:x:27:sysadmin/' /etc/group +run sed -Ei 's/(\%sudo\s+ALL=\(ALL\:ALL\) )ALL/\1 NOPASSWD:ALL/' /etc/sudoers + +# Autorun firefox. -no-remote is necessary to create a new container, as firefox +# appears to communicate with itself through X11. +cmd ["/bin/sh", "-c", "/usr/bin/sudo -u sysadmin -H -E /application/firefox/firefox -no-remote"]