Docker, start image from scratch

6

5

All getting-started guides for Docker based their docker images on someone else's. However, even the base image has 180MB of virtual storage there. So,

I'm wondering, is it possible to start my docker image completely from scratch without any parent images? (If so, I'm planning to create my own base image via a net-install).

PS check here for more about Docker

Thanks

xpt

Posted 2013-11-03T22:45:00.587

Reputation: 5 548

Answers

5

Find it,

How to build base boxes for Docker

Recap the steps that I had always been doing,

First make sure the debootstrap is installed:

 sudo apt-get install debootstrap

Then get the latest mkimage-debootstrap.sh:

sudo sh -xc 'curl https://raw.githubusercontent.com/dotcloud/docker/master/contrib/mkimage-debootstrap.sh > /usr/sbin/mkimage-debootstrap.sh' sudo chmod 755 /usr/sbin/mkimage-debootstrap.sh

The build step is very simple:

mkimage-debootstrap.sh sfxpt/debian sid

for Debian, and

mkimage-debootstrap.sh sfxpt/ubuntu saucy

for building an Ubuntu docker image.

Checkout the above url for all the missing details. And also,

How can I make my own base image for Docker

xpt

Posted 2013-11-03T22:45:00.587

Reputation: 5 548

2

Docker Hub would be a good place to look. Gentoo is a typical preference as well as GitHub, however the registry on Docker Hub often has the links to dockerfile/s used to create the DOCker container.

As well one can Nest Docker Containers into one another. You can also use Docker Compose, pull a reference image push to yourname/mycustom-container-squash

Dockerfile 
FROM myname/my-custom-container 
ADD Build-all-my-crap.sh
RUN Build-all-my-crap.sh

As well as with VirtualBox, you can use BusyBox unpacked binaries, i.e. de-crufting Debian files for pure tar.gz i.e. bin >tar.gz , etc. and using bb-tar.gz and from scratch to unpack tarballs for a minimal base.

In my case I was tinkering with Gentoo to Pentoo, however the iso >out to get to the squashfiles, though I can add the overlay, the docker-hub server will kill the build if it takes too long. I figured just overwriting the Gentoo install with Pentoo (customized Gentoo) or next try to add overlay rsync/crsync binpackage then just emerge pkg list, clean out bins, but again this will likely time out.

Jenkler Docker Base Gentoo package on GitHub

I used the Gentoo official repo, however their shell tool tends to fail at dockerhub autobuilds for x86-hardened. (bummer)

Jenkler's method allows for a minimal yet tweaked base image. I can slide a few debian>tar into the fray temporarily, and or just build them in. GitHub allows for a bit of LFS, so I could just chop up my dir>tarballs like the example above. As I've tried to slice off the iso and squashfile, and it's not working as well as I would care for.

necrose99/my-cx-gentoo base from, use a few tools to unpack the squashfs. i.e. for some security research, being able to docker cluster or set up Pentoo in a Docker as a chroot like... (can run x11, etc.) for doing builds that might not do so healthy things to my REAL install (ALPHA packages I'm not the greatest Ebuild writer plus newer security tools).

however my new container call in my-base
emerge my new stuff
next new container call in old/old/some else from build tabs. on Docker Hub.
Not to drone on and get the moderators all mad...

Anyhow you can stack Docker images like cake layers to make a wedding cake would be a good analogy and/or kick an app into a container and build it from a base container. my-debian-ngix-www-hugo-docker from debian/public... , etc. can if Debian is your base of choice.

Necrose99

Posted 2013-11-03T22:45:00.587

Reputation: 51

1

anyhow you can load your Linux os of choice , https://github.com/Jenkler/docker/tree/master/gentoo-base , clone or download as zip , install your linux , and just hack each of the main dirs up into tarballs, usefull if thier is no official base for your distro. however if your distro is a Debian/Ubuntu variant /redhat/centos/etc, easier to FROM THEM/THEM, RUN the add repo command to add your deb/rpm repo's , then ADD packages. IE DEBIAN add kahli Linux repo, add pkgs.

– Necrose99 – 2015-11-21T04:01:16.320

Thanks for the comprehensive answer, but I more feel it is more a generic talk, instead of targeting the specific OP question, I.e., how to create docker image completely from scratch without any parent images, and too much irrelevant information can be more distracting than helpful. But still, the answer is nonetheless still a good read and good source of info. – xpt – 2015-11-21T15:10:55.433

1

FROM scratch MAINTAINER Mikael Jenkler info@jenkler.com ADD gentoo1.tar.xz / ADD gentoo2.tar.xz / ADD gentoo3.tar.xz / ADD gentoo4.tar.xz / ADD gentoo5.tar.xz / CMD ["/bin/bash"] anyhow this one they just carved up a minimal gentoo install. ARCH ? or etc , same could be applied.

– Necrose99 – 2015-11-22T05:20:30.463

1ADD my-provision.sh – Necrose99 – 2015-11-22T05:28:05.920

1ADD my-provision.sh; RUN provision.sh bash script to unpack the tarball shards, git some package , pkg-manager command , ie apt-get/equo/emerge/yum/packman some package/s , you can then call the base container into another image. virtualbox livedvd , unpack your distro's into CHROOT, or debian net install , reboot virtualbox for gui, and or run docker compose, however via dockerfile , image can be updated via docker hub autobuilds. – Necrose99 – 2015-11-22T05:33:45.130

2https://github.com/Jenkler/docker/tree/master/gentoo-base ,https://github.com/Jenkler/docker/tree/master/gentoo-base/build just clone trim to what you require for your distro needed. . – Necrose99 – 2015-11-22T05:43:13.303