baseimages.rst 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. :title: Create a Base Image
  2. :description: How to create base images
  3. :keywords: Examples, Usage, base image, docker, documentation, examples
  4. .. _base_image_creation:
  5. Create a Base Image
  6. ===================
  7. So you want to create your own :ref:`base_image_def`? Great!
  8. The specific process will depend heavily on the Linux distribution you
  9. want to package. We have some examples below, and you are encouraged
  10. to submit pull requests to contribute new ones.
  11. Create a full image using tar
  12. .............................
  13. In general, you'll want to start with a working machine that is
  14. running the distribution you'd like to package as a base image, though
  15. that is not required for some tools like Debian's `Debootstrap
  16. <https://wiki.debian.org/Debootstrap>`_, which you can also use to
  17. build Ubuntu images.
  18. It can be as simple as this to create an Ubuntu base image::
  19. $ sudo debootstrap raring raring > /dev/null
  20. $ sudo tar -C raring -c . | sudo docker import - raring
  21. a29c15f1bf7a
  22. $ sudo docker run raring cat /etc/lsb-release
  23. DISTRIB_ID=Ubuntu
  24. DISTRIB_RELEASE=13.04
  25. DISTRIB_CODENAME=raring
  26. DISTRIB_DESCRIPTION="Ubuntu 13.04"
  27. There are more example scripts for creating base images in the
  28. Docker GitHub Repo:
  29. * `BusyBox <https://github.com/dotcloud/docker/blob/master/contrib/mkimage-busybox.sh>`_
  30. * CentOS / Scientific Linux CERN (SLC) `on Debian/Ubuntu
  31. <https://github.com/dotcloud/docker/blob/master/contrib/mkimage-rinse.sh>`_
  32. or
  33. `on CentOS/RHEL/SLC/etc.
  34. <https://github.com/dotcloud/docker/blob/master/contrib/mkimage-yum.sh>`_
  35. * `Debian / Ubuntu
  36. <https://github.com/dotcloud/docker/blob/master/contrib/mkimage-debootstrap.sh>`_
  37. Creating a simple base image using ``scratch``
  38. ..............................................
  39. There is a special repository in the Docker registry called ``scratch``, which
  40. was created using an empty tar file::
  41. $ tar cv --files-from /dev/null | docker import - scratch
  42. which you can ``docker pull``. You can then use that image to base your new
  43. minimal containers ``FROM``::
  44. FROM scratch
  45. ADD true-asm /true
  46. CMD ["/true"]
  47. The Dockerfile above is from extremely minimal image -
  48. `tianon/true <https://github.com/tianon/dockerfiles/tree/master/true>`_.