github.com/feiyang21687/docker@v1.5.0/docs/sources/articles/baseimages.md (about)

     1  page_title: Create a Base Image
     2  page_description: How to create base images
     3  page_keywords: Examples, Usage, base image, docker, documentation, examples
     4  
     5  # Create a Base Image
     6  
     7  So you want to create your own [*Base Image*](
     8  /terms/image/#base-image)? Great!
     9  
    10  The specific process will depend heavily on the Linux distribution you
    11  want to package. We have some examples below, and you are encouraged to
    12  submit pull requests to contribute new ones.
    13  
    14  ## Create a full image using tar
    15  
    16  In general, you'll want to start with a working machine that is running
    17  the distribution you'd like to package as a base image, though that is
    18  not required for some tools like Debian's
    19  [Debootstrap](https://wiki.debian.org/Debootstrap), which you can also
    20  use to build Ubuntu images.
    21  
    22  It can be as simple as this to create an Ubuntu base image:
    23  
    24      $ sudo debootstrap raring raring > /dev/null
    25      $ sudo tar -C raring -c . | sudo docker import - raring
    26      a29c15f1bf7a
    27      $ sudo docker run raring cat /etc/lsb-release
    28      DISTRIB_ID=Ubuntu
    29      DISTRIB_RELEASE=13.04
    30      DISTRIB_CODENAME=raring
    31      DISTRIB_DESCRIPTION="Ubuntu 13.04"
    32  
    33  There are more example scripts for creating base images in the Docker
    34  GitHub Repo:
    35  
    36   - [BusyBox](https://github.com/docker/docker/blob/master/contrib/mkimage-busybox.sh)
    37   - CentOS / Scientific Linux CERN (SLC) [on Debian/Ubuntu](
    38     https://github.com/docker/docker/blob/master/contrib/mkimage-rinse.sh) or
    39     [on CentOS/RHEL/SLC/etc.](
    40     https://github.com/docker/docker/blob/master/contrib/mkimage-yum.sh)
    41   - [Debian / Ubuntu](
    42     https://github.com/docker/docker/blob/master/contrib/mkimage-debootstrap.sh)
    43  
    44  ## Creating a simple base image using `scratch`
    45  
    46  There is a special repository in the Docker registry called `scratch`, which
    47  was created using an empty tar file:
    48  
    49      $ tar cv --files-from /dev/null | docker import - scratch
    50  
    51  which you can `docker pull`. You can then use that
    52  image to base your new minimal containers `FROM`:
    53  
    54      FROM scratch
    55      COPY true-asm /true
    56      CMD ["/true"]
    57  
    58  The `Dockerfile` above is from an extremely minimal image - [tianon/true](
    59  https://github.com/tianon/dockerfiles/tree/master/true).
    60  
    61  ## More resources
    62  
    63  There are lots more resources available to help you write your 'Dockerfile`.
    64  
    65  * There's a [complete guide to all the instructions](/reference/builder/) available for use in a `Dockerfile` in the reference section.
    66  * To help you write a clear, readable, maintainable `Dockerfile`, we've also
    67  written a [`Dockerfile` Best Practices guide](/articles/dockerfile_best-practices).
    68  * If you're working on an Official Repo, be sure to check out the [Official Repo Guidelines](/docker-hub/official_repos/).