Differences between revisions 1 and 17 (spanning 16 versions)
Revision 1 as of 2014-03-05 17:05:17
Size: 552
Comment:
Revision 17 as of 2015-05-14 13:49:48
Size: 3576
Editor: jmtd
Comment: expand manual method with my makefiles/dockerfiles
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
Hints on how to create a Debian image for [[Docker]]. This page attempts to document how to create a Debian image for [[Docker]].
Line 3: Line 3:
See http://sfxpt.wordpress.com/2013/11/17/debianubuntu-package-developing-with-docker-continued/ for original reference. You may use Debian images from [[https://index.docker.io/_/debian/|Docker.io's Debian official repository]] if you trust their author, or you may prefer to create them yourself, using the methods described below.
Line 5: Line 5:
The following is work in progress WITHOUT ANY WARANTY '''The following is work in progress WITHOUT ANY WARRANTY'''
Line 7: Line 7:
Note that due to bug #740855 `/usr/share/docker.io/contrib/mkimage-debootstrap.sh` needs to be patched at the moment. You may use one of the following methods :
 * upstream-provided mkimage.sh + mkimage/debootstrap,
 * or older upstream-provided mkimage-debootstrap.sh,
 * or manual install
Line 9: Line 12:
You may create an image with : == Using (upstream provided "contrib" script) mkimage.sh ==

The `docker.io` package ships the `/usr/share/docker.io/contrib/mkimage.sh` script which may be used, alongside the companion script `/usr/share/docker.io/contrib/mkimage/debootstrap` to create a Docker image for Debian (or Ubuntu) using `debootstrap`, and with or without further tweaks.

You may create an image for the `stable` suite (using the `minbase` debootstrap variant) with :
Line 11: Line 18:
.../mkimage-debootstrap.sh $USER/debian sid sudo .../mkimage.sh -t $USER/minbase debootstrap --variant=minbase stable
Line 16: Line 23:
sudo docker.io run -i $USER/debian:sid echo "hello world" sudo docker.io run -i $USER/minbase echo "hello world"
Line 18: Line 25:

Contrary to the former mkimage-debootstrap.sh (now deprecated, see below), contrib/mkimage/debootstrap does not need the mandatory `variant` parameter, and can invoke debootstrap without a specific variant, using its default settings.

== Using mkimage-debootstrap.sh (now flagged as deprecated by upstream) ==

The `docker.io` package still ships the, now deprecated, `/usr/share/docker.io/contrib/mkimage-debootstrap.sh` script which may be used to create a Docker image for Debian (or Ubuntu) using `debootstrap`, and with or without further tweaks.

You may create an image for the `stable` suite (using the `minbase` debootstrap variant) with :
{{{
.../mkimage-debootstrap.sh $USER/minbase stable
}}}

The image may then be used with :
{{{
sudo docker.io run -i $USER/minbase:stable echo "hello world"
}}}

As an alternative to upstream's choices, you may modify the script so that it does not use the minbase variant by default (see for instance [[https://raw.github.com/olberger/docker/debian/contrib/mkimage-debootstrap.sh|obergix's version]] and adjust to your needs), or use the newer mkimage.sh (see above).

== Manual method ==

To build pristine debian images, without cloud/docker-specific, customisations, you can use the scripts at <https://github.com/jmtd/debian-docker>. These use {{{debootstrap}}} to prepare a basic filesystem and add them into a docker image. Suggestions for improvements are very welcome.

Images built from these scripts are pushed to the Docker Registry as {{{jmtd/debian:wheezy}}}, {{{jmtd/debian:jessie}}} etc., but there is presently no image verification in place (so no way to cryptographically prove the provenance of the images).

See also <http://www.debian-administration.org/article/696/A_brief_introduction_to_using_docker#a2>.

== Using the newly built image to create a test container ==

A dockerfile may then refer to your image using the following directive :
{{{
FROM YOURUSER/minbase:stable
}}}

You may test it with :
{{{
echo "FROM $USER/minbase:stable" | docker.io build -t $USER/test:stable -
}}}

== Resources ==
 * See http://sfxpt.wordpress.com/2013/11/17/debianubuntu-package-developing-with-docker-continued/ for a description of using `mkimage-debootstrap.sh`.
 * Nickoloff, Jeff, Docker in Action (http://www.manning.com/nickoloff/), Manning Publications, 2014, ISBN 978-1-6334-3023-5

This page attempts to document how to create a Debian image for Docker.

You may use Debian images from Docker.io's Debian official repository if you trust their author, or you may prefer to create them yourself, using the methods described below.

The following is work in progress WITHOUT ANY WARRANTY

You may use one of the following methods :

  • upstream-provided mkimage.sh + mkimage/debootstrap,
  • or older upstream-provided mkimage-debootstrap.sh,
  • or manual install

Using (upstream provided "contrib" script) mkimage.sh

The docker.io package ships the /usr/share/docker.io/contrib/mkimage.sh script which may be used, alongside the companion script /usr/share/docker.io/contrib/mkimage/debootstrap to create a Docker image for Debian (or Ubuntu) using debootstrap, and with or without further tweaks.

You may create an image for the stable suite (using the minbase debootstrap variant) with :

sudo .../mkimage.sh -t $USER/minbase debootstrap --variant=minbase stable

The image may then be used with :

sudo docker.io run -i $USER/minbase echo "hello world"

Contrary to the former mkimage-debootstrap.sh (now deprecated, see below), contrib/mkimage/debootstrap does not need the mandatory variant parameter, and can invoke debootstrap without a specific variant, using its default settings.

Using mkimage-debootstrap.sh (now flagged as deprecated by upstream)

The docker.io package still ships the, now deprecated, /usr/share/docker.io/contrib/mkimage-debootstrap.sh script which may be used to create a Docker image for Debian (or Ubuntu) using debootstrap, and with or without further tweaks.

You may create an image for the stable suite (using the minbase debootstrap variant) with :

.../mkimage-debootstrap.sh $USER/minbase stable

The image may then be used with :

sudo docker.io run -i $USER/minbase:stable echo "hello world"

As an alternative to upstream's choices, you may modify the script so that it does not use the minbase variant by default (see for instance obergix's version and adjust to your needs), or use the newer mkimage.sh (see above).

Manual method

To build pristine debian images, without cloud/docker-specific, customisations, you can use the scripts at <https://github.com/jmtd/debian-docker>. These use debootstrap to prepare a basic filesystem and add them into a docker image. Suggestions for improvements are very welcome.

Images built from these scripts are pushed to the Docker Registry as jmtd/debian:wheezy, jmtd/debian:jessie etc., but there is presently no image verification in place (so no way to cryptographically prove the provenance of the images).

See also <http://www.debian-administration.org/article/696/A_brief_introduction_to_using_docker#a2>.

Using the newly built image to create a test container

A dockerfile may then refer to your image using the following directive :

FROM YOURUSER/minbase:stable

You may test it with :

echo "FROM $USER/minbase:stable" | docker.io build -t $USER/test:stable -

Resources