Docker - Why, How to Build Custom Images

As a follow up to my “How to: Docker on openSUSE”
https://forums.opensuse.org/showthread.php/500072-How-to-Docker-on-openSUSE

The following describes why, and how to create a custom image in Docker
http://en.opensuse.org/User:Tsu2/docker-build-tutorial-1

Docker is a powerful way to deploy Linux Containers.
But, public images of apps and OS are typically very generic and may not include the most basic configurations.
You can create images and containers passing options at the command line, but that’s very unwieldy and can be subject to errors.

Much cleaner is to simply create a custom image based on the generic image with your specified options, and this tutorial I posted walks the User through the most basic steps. From there, you can apply the same steps other options listed in the Docker Build reference (I provide the link).

TSU

Nice orientation, Tsu.

Any idea where to get a docker image for opensuse 42.1 ?:open_mouth:

Thx for the props…

How 'bout that… I haven’t had occasion to check for an official 14.1 image, I’d recommend submitting a request through https://bugzilla.opensuse.org.

But, in the meantime it should be possible to deploy a 13.2 and upgrade it to 14.1 using the usual online upgrade process… which is to simply change the repos and then run a “zypper dup.”

For anyone who does this, I’d probably also recommend experimenting installing the cloud-init package from the cloud repo which sets up ssh authentication. Although it was designed for openstack integration for normal paravirtualized guests, from what I’ve read and seen it <might> also be beneficial in a Docker container.

Keep in mind also that my articles were written nearly 2 years ago and Docker has been moving <very> fast.
Since I wrote those papers, latest Docker images have slimmed down immensely and today is comparable to the Debian image (by reputation most popular in part because they are smallest in size)
The networking exercises I describe are still supported, but Docker just recently (approx Dec 2015) introduced a new way to do networking. Your choice which to implement.

TSU

Ok, I’ll have a look at cloud-init packages, where special boot commands are implemented when on ec2 or similar…

I could finally find my way for opensuse 42.1 images.

There are three ways, so far to proceed with:

1. Seed a new container from an opensuse hub.docker.com images.

docker pull opensuse

**2. Download the Dockerfile and tarball from ** and
https://github.com/openSUSE/docker-containers-build/blob/70d5db31fd5357d4d36170570d215120800b4f3c/docker

there are two files to download : Dockerfile ( can be enhanced ) and the base tarball.

docker import - myopensuse < /path/to/openSUSE-42.1.tar.xz

requires the Dockerfile in the same directory as the run import.

[FONT=comic sans ms]Not much different from 1, except that it exposes some container with systemd preinstalled…

**3. Build your own tarball with Kiwi commands:

https://github.com/openSUSE/docker-containers**

examples can be found in Kiwi doc directory: /usr/share/doc/packages/kiwi/suse-13.1

docker import - mykiwiopensuse < /path/to/kiwiSUSE-42.1.tar.xz

requiring the following files:

  • config.xml
  • config.sh

and a directory structures like

/root/etc/zypp/repos.d

with inside the repos file descriptors ex:

repo-oss.repo

[repo-oss]
name=openSUSE-Leap-42.1-Oss
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/distribution/leap/42.1/repo/oss/
path=/
type=yast2
keeppackages=1

The real challenge here is to find the secret recipe to minimize packages ( through usage of patterns in config.xml) :
the one not really required and the one needed for our further container installs,
and that are relevant for a docker container, including incorporating cloud-init/networking considerations…

And I faced an issue with one pattern openSUSE-mini-release declared not to be present :, then I replaced it with openSUSE-minimal_base…
I probably miss something looking for package openSUSE-mini-release in the wrong environment.

Cheers,

[/FONT]

Exactly.

Flavio is the foremost expert on Kiwi and his work with JeOS (Just enough OS) and unless/until he publishes a detailed description how he shrunk prior images, only he can do the work to create a highly minimized image… unless I guess, someone reverse engineered what he did using something like diff.

http://flavio.castelli.name/2015/07/24/putting-opensuse-docker-images-on-a-diet/

TSU