github.com/slava-ustovytski/docker@v1.8.2-rc1/project/PACKAGERS.md (about)

     1  # Dear Packager,
     2  
     3  If you are looking to make Docker available on your favorite software
     4  distribution, this document is for you. It summarizes the requirements for
     5  building and running the Docker client and the Docker daemon.
     6  
     7  ## Getting Started
     8  
     9  We want to help you package Docker successfully. Before doing any packaging, a
    10  good first step is to introduce yourself on the [docker-dev mailing
    11  list](https://groups.google.com/d/forum/docker-dev), explain what you're trying
    12  to achieve, and tell us how we can help. Don't worry, we don't bite! There might
    13  even be someone already working on packaging for the same distro!
    14  
    15  You can also join the IRC channel - #docker and #docker-dev on Freenode are both
    16  active and friendly.
    17  
    18  We like to refer to Tianon ("@tianon" on GitHub and "tianon" on IRC) as our
    19  "Packagers Relations", since he's always working to make sure our packagers have
    20  a good, healthy upstream to work with (both in our communication and in our
    21  build scripts). If you're having any kind of trouble, feel free to ping him
    22  directly. He also likes to keep track of what distributions we have packagers
    23  for, so feel free to reach out to him even just to say "Hi!"
    24  
    25  ## Package Name
    26  
    27  If possible, your package should be called "docker". If that name is already
    28  taken, a second choice is "docker-engine". Another possible choice is "docker.io".
    29  
    30  ## Official Build vs Distro Build
    31  
    32  The Docker project maintains its own build and release toolchain. It is pretty
    33  neat and entirely based on Docker (surprise!). This toolchain is the canonical
    34  way to build Docker. We encourage you to give it a try, and if the circumstances
    35  allow you to use it, we recommend that you do.
    36  
    37  You might not be able to use the official build toolchain - usually because your
    38  distribution has a toolchain and packaging policy of its own. We get it! Your
    39  house, your rules. The rest of this document should give you the information you
    40  need to package Docker your way, without denaturing it in the process.
    41  
    42  ## Build Dependencies
    43  
    44  To build Docker, you will need the following:
    45  
    46  * A recent version of Git and Mercurial
    47  * Go version 1.4 or later
    48  * A clean checkout of the source added to a valid [Go
    49    workspace](https://golang.org/doc/code.html#Workspaces) under the path
    50    *src/github.com/docker/docker* (unless you plan to use `AUTO_GOPATH`,
    51    explained in more detail below)
    52  
    53  To build the Docker daemon, you will additionally need:
    54  
    55  * An amd64/x86_64 machine running Linux
    56  * SQLite version 3.7.9 or later
    57  * libdevmapper version 1.02.68-cvs (2012-01-26) or later from lvm2 version
    58    2.02.89 or later
    59  * btrfs-progs version 3.16.1 or later (unless using an older version is
    60    absolutely necessary, in which case 3.8 is the minimum)
    61  
    62  Be sure to also check out Docker's Dockerfile for the most up-to-date list of
    63  these build-time dependencies.
    64  
    65  ### Go Dependencies
    66  
    67  All Go dependencies are vendored under "./vendor". They are used by the official
    68  build, so the source of truth for the current version of each dependency is
    69  whatever is in "./vendor".
    70  
    71  To use the vendored dependencies, simply make sure the path to "./vendor" is
    72  included in `GOPATH` (or use `AUTO_GOPATH`, as explained below).
    73  
    74  If you would rather (or must, due to distro policy) package these dependencies
    75  yourself, take a look at "./hack/vendor.sh" for an easy-to-parse list of the
    76  exact version for each.
    77  
    78  NOTE: if you're not able to package the exact version (to the exact commit) of a
    79  given dependency, please get in touch so we can remediate! Who knows what
    80  discrepancies can be caused by even the slightest deviation. We promise to do
    81  our best to make everybody happy.
    82  
    83  ## Stripping Binaries
    84  
    85  Please, please, please do not strip any compiled binaries. This is really
    86  important.
    87  
    88  In our own testing, stripping the resulting binaries sometimes results in a
    89  binary that appears to work, but more often causes random panics, segfaults, and
    90  other issues. Even if the binary appears to work, please don't strip.
    91  
    92  See the following quotes from Dave Cheney, which explain this position better
    93  from the upstream Golang perspective.
    94  
    95  ### [go issue #5855, comment #3](https://code.google.com/p/go/issues/detail?id=5855#c3)
    96  
    97  > Super super important: Do not strip go binaries or archives. It isn't tested,
    98  > often breaks, and doesn't work.
    99  
   100  ### [launchpad golang issue #1200255, comment #8](https://bugs.launchpad.net/ubuntu/+source/golang/+bug/1200255/comments/8)
   101  
   102  > To quote myself: "Please do not strip Go binaries, it is not supported, not
   103  > tested, is often broken, and doesn't do what you want"
   104  >
   105  > To unpack that a bit
   106  >
   107  > * not supported, as in, we don't support it, and recommend against it when
   108  >   asked
   109  > * not tested, we don't test stripped binaries as part of the build CI process
   110  > * is often broken, stripping a go binary will produce anywhere from no, to
   111  >   subtle, to outright execution failure, see above
   112  
   113  ### [launchpad golang issue #1200255, comment #13](https://bugs.launchpad.net/ubuntu/+source/golang/+bug/1200255/comments/13)
   114  
   115  > To clarify my previous statements.
   116  >
   117  > * I do not disagree with the debian policy, it is there for a good reason
   118  > * Having said that, it stripping Go binaries doesn't work, and nobody is
   119  >   looking at making it work, so there is that.
   120  >
   121  > Thanks for patching the build formula.
   122  
   123  ## Building Docker
   124  
   125  Please use our build script ("./hack/make.sh") for all your compilation of
   126  Docker. If there's something you need that it isn't doing, or something it could
   127  be doing to make your life as a packager easier, please get in touch with Tianon
   128  and help us rectify the situation. Chances are good that other packagers have
   129  probably run into the same problems and a fix might already be in the works, but
   130  none of us will know for sure unless you harass Tianon about it. :)
   131  
   132  All the commands listed within this section should be run with the Docker source
   133  checkout as the current working directory.
   134  
   135  ### `AUTO_GOPATH`
   136  
   137  If you'd rather not be bothered with the hassles that setting up `GOPATH`
   138  appropriately can be, and prefer to just get a "build that works", you should
   139  add something similar to this to whatever script or process you're using to
   140  build Docker:
   141  
   142  ```bash
   143  export AUTO_GOPATH=1
   144  ```
   145  
   146  This will cause the build scripts to set up a reasonable `GOPATH` that
   147  automatically and properly includes both docker/docker from the local
   148  directory, and the local "./vendor" directory as necessary.
   149  
   150  ### `DOCKER_BUILDTAGS`
   151  
   152  If you're building a binary that may need to be used on platforms that include
   153  AppArmor, you will need to set `DOCKER_BUILDTAGS` as follows:
   154  ```bash
   155  export DOCKER_BUILDTAGS='apparmor'
   156  ```
   157  
   158  If you're building a binary that may need to be used on platforms that include
   159  SELinux, you will need to use the `selinux` build tag:
   160  ```bash
   161  export DOCKER_BUILDTAGS='selinux'
   162  ```
   163  
   164  There are build tags for disabling graphdrivers as well. By default, support
   165  for all graphdrivers are built in.
   166  
   167  To disable btrfs:
   168  ```bash
   169  export DOCKER_BUILDTAGS='exclude_graphdriver_btrfs'
   170  ```
   171  
   172  To disable devicemapper:
   173  ```bash
   174  export DOCKER_BUILDTAGS='exclude_graphdriver_devicemapper'
   175  ```
   176  
   177  To disable aufs:
   178  ```bash
   179  export DOCKER_BUILDTAGS='exclude_graphdriver_aufs'
   180  ```
   181  
   182  NOTE: if you need to set more than one build tag, space separate them:
   183  ```bash
   184  export DOCKER_BUILDTAGS='apparmor selinux exclude_graphdriver_aufs'
   185  ```
   186  
   187  ### Static Daemon
   188  
   189  If it is feasible within the constraints of your distribution, you should
   190  seriously consider packaging Docker as a single static binary. A good comparison
   191  is Busybox, which is often packaged statically as a feature to enable mass
   192  portability. Because of the unique way Docker operates, being similarly static
   193  is a "feature".
   194  
   195  To build a static Docker daemon binary, run the following command (first
   196  ensuring that all the necessary libraries are available in static form for
   197  linking - see the "Build Dependencies" section above, and the relevant lines
   198  within Docker's own Dockerfile that set up our official build environment):
   199  
   200  ```bash
   201  ./hack/make.sh binary
   202  ```
   203  
   204  This will create a static binary under
   205  "./bundles/$VERSION/binary/docker-$VERSION", where "$VERSION" is the contents of
   206  the file "./VERSION". This binary is usually installed somewhere like
   207  "/usr/bin/docker".
   208  
   209  ### Dynamic Daemon / Client-only Binary
   210  
   211  If you are only interested in a Docker client binary, set `DOCKER_CLIENTONLY` to a non-empty value using something similar to the following: (which will prevent the extra step of compiling dockerinit)
   212  
   213  ```bash
   214  export DOCKER_CLIENTONLY=1
   215  ```
   216  
   217  If you need to (due to distro policy, distro library availability, or for other
   218  reasons) create a dynamically compiled daemon binary, or if you are only
   219  interested in creating a client binary for Docker, use something similar to the
   220  following:
   221  
   222  ```bash
   223  ./hack/make.sh dynbinary
   224  ```
   225  
   226  This will create "./bundles/$VERSION/dynbinary/docker-$VERSION", which for
   227  client-only builds is the important file to grab and install as appropriate.
   228  
   229  For daemon builds, you will also need to grab and install
   230  "./bundles/$VERSION/dynbinary/dockerinit-$VERSION", which is created from the
   231  minimal set of Docker's codebase that _must_ be compiled statically (and is thus
   232  a pure static binary). The acceptable locations Docker will search for this file
   233  are as follows (in order):
   234  
   235  * as "dockerinit" in the same directory as the daemon binary (ie, if docker is
   236    installed at "/usr/bin/docker", then "/usr/bin/dockerinit" will be the first
   237    place this file is searched for)
   238  * "/usr/libexec/docker/dockerinit" or "/usr/local/libexec/docker/dockerinit"
   239    ([FHS 3.0 Draft](https://www.linuxbase.org/betaspecs/fhs/fhs.html#usrlibexec))
   240  * "/usr/lib/docker/dockerinit" or "/usr/local/lib/docker/dockerinit" ([FHS
   241    2.3](https://refspecs.linuxfoundation.org/FHS_2.3/fhs-2.3.html#USRLIBLIBRARIESFORPROGRAMMINGANDPA))
   242  
   243  If (and please, only if) one of the paths above is insufficient due to distro
   244  policy or similar issues, you may use the `DOCKER_INITPATH` environment variable
   245  at compile-time as follows to set a different path for Docker to search:
   246  
   247  ```bash
   248  export DOCKER_INITPATH=/usr/lib/docker.io/dockerinit
   249  ```
   250  
   251  If you find yourself needing this, please don't hesitate to reach out to Tianon
   252  to see if it would be reasonable or helpful to add more paths to Docker's list,
   253  especially if there's a relevant standard worth referencing (such as the FHS).
   254  
   255  Also, it goes without saying, but for the purposes of the daemon please consider
   256  these two binaries ("docker" and "dockerinit") as if they were a single unit.
   257  Mixing and matching can cause undesired consequences, and will fail to run
   258  properly.
   259  
   260  ## System Dependencies
   261  
   262  ### Runtime Dependencies
   263  
   264  To function properly, the Docker daemon needs the following software to be
   265  installed and available at runtime:
   266  
   267  * iptables version 1.4 or later
   268  * procps (or similar provider of a "ps" executable)
   269  * e2fsprogs version 1.4.12 or later (in use: mkfs.ext4, mkfs.xfs, tune2fs)
   270  * XZ Utils version 4.9 or later
   271  * a [properly
   272    mounted](https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount)
   273    cgroupfs hierarchy (having a single, all-encompassing "cgroup" mount point
   274    [is](https://github.com/docker/docker/issues/2683)
   275    [not](https://github.com/docker/docker/issues/3485)
   276    [sufficient](https://github.com/docker/docker/issues/4568))
   277  
   278  Additionally, the Docker client needs the following software to be installed and
   279  available at runtime:
   280  
   281  * Git version 1.7 or later
   282  
   283  ### Kernel Requirements
   284  
   285  The Docker daemon has very specific kernel requirements. Most pre-packaged
   286  kernels already include the necessary options enabled. If you are building your
   287  own kernel, you will either need to discover the options necessary via trial and
   288  error, or check out the [Gentoo
   289  ebuild](https://github.com/tianon/docker-overlay/blob/master/app-emulation/docker/docker-9999.ebuild),
   290  in which a list is maintained (and if there are any issues or discrepancies in
   291  that list, please contact Tianon so they can be rectified).
   292  
   293  Note that in client mode, there are no specific kernel requirements, and that
   294  the client will even run on alternative platforms such as Mac OS X / Darwin.
   295  
   296  ### Optional Dependencies
   297  
   298  Some of Docker's features are activated by using optional command-line flags or
   299  by having support for them in the kernel or userspace. A few examples include:
   300  
   301  * LXC execution driver (requires version 1.0.7 or later of lxc and the lxc-libs)
   302  * AUFS graph driver (requires AUFS patches/support enabled in the kernel, and at
   303    least the "auplink" utility from aufs-tools)
   304  * BTRFS graph driver (requires BTRFS support enabled in the kernel)
   305  * ZFS graph driver (requires userspace zfs-utils and a corresponding kernel module)
   306  
   307  ## Daemon Init Script
   308  
   309  Docker expects to run as a daemon at machine startup. Your package will need to
   310  include a script for your distro's process supervisor of choice. Be sure to
   311  check out the "contrib/init" folder in case a suitable init script already
   312  exists (and if one does not, contact Tianon about whether it might be
   313  appropriate for your distro's init script to live there too!).
   314  
   315  In general, Docker should be run as root, similar to the following:
   316  
   317  ```bash
   318  docker -d
   319  ```
   320  
   321  Generally, a `DOCKER_OPTS` variable of some kind is available for adding more
   322  flags (such as changing the graph driver to use BTRFS, switching the location of
   323  "/var/lib/docker", etc).
   324  
   325  ## Communicate
   326  
   327  As a final note, please do feel free to reach out to Tianon at any time for
   328  pretty much anything. He really does love hearing from our packagers and wants
   329  to make sure we're not being a "hostile upstream". As should be a given, we
   330  appreciate the work our packagers do to make sure we have broad distribution!