Building a Docker Base Image Without Using a Dockerfile
Sometimes we need a base image that is not built from a Dockerfile, but instead created directly from an ISO, debootstrap environment, or distribution build tools.
Below are several practical approaches.
1. Importing from an ISO Image
If you have a Linux installation ISO (for example, Ubuntu), you can mount it and pipe its filesystem into Docker.
Step 1: Mount the ISO
sudo mount -o loop ubuntu-14.04-server-amd64.iso /media/cdrom
Step 2: Import into Docker
sudo tar -C /media/cdrom -c . | docker import - guol/ubuntu14
This creates a Docker image named guol/ubuntu14.
Note: This method imports raw filesystem content and does not include Docker metadata or optimized layering.
2. Using debootstrap (Debian/Ubuntu)
A cleaner approach for Debian-based systems is to use debootstrap to create a minimal root filesystem.
Step 1: Install debootstrap
sudo zypper in debootstrap
Step 2: Create a Chroot Filesystem
sudo debootstrap --arch amd64 sid /sid-chroot http://deb.debian.org/debian/
This creates a minimal Debian SID root filesystem in /sid-chroot.
Step 3: Import into Docker
sudo tar -C /sid-chroot -c . | sudo docker import - sid
Step 4: Run the Container
sudo docker run -ti sid /bin/bash
This gives you a minimal Debian container environment.
3. fdebootstrap
fdebootstrap is similar to debootstrap but provides additional features for full Debian root filesystem creation.
(Implementation details to be expanded.)
4. Building a SUSE-Based Docker Image with KIWI
For SUSE distributions, the recommended approach is to use the KIWI image build system.
Step 1: Install KIWI
sudo zypper in kiwi kiwi-doc
Step 2: Copy Example Configuration
mkdir suse
cd suse
sudo cp -r /usr/share/doc/packages/kiwi/examples/suse-13.1/ .
Step 3: Edit Configuration
Modify config.xml according to your needs.
Step 4: Prepare Build Directory
mkdir image/
Step 5: Build the Image
sudo kiwi -p suse-13.1/suse-docker-container --root image/
sudo kiwi --create image --type docker -d image-result
Step 6: Import into Docker
sudo docker import image-result/image.tar.xz myimage
You now have a SUSE-based Docker image built using KIWI.
Summary
There are multiple ways to create a base Docker image without using a Dockerfile:
- Import directly from an ISO
- Create a minimal root filesystem using debootstrap
- Use fdebootstrap for more advanced setups
- Use KIWI for SUSE-based distributions
Each approach has trade-offs:
- ISO import is quick but less clean
- debootstrap provides a minimal and controlled environment
- KIWI integrates cleanly with SUSE packaging
Choose the method that best fits your distribution and workflow.