.. _docker-plugin: Docker Plugin ============= Docker images describe how to set up a container for running an application, including what files are present, and what program to run. https://docs.docker.com/introduction/understanding-docker/ provides an introduction to Docker. https://docs.docker.com/reference/builder/ describes the ``Dockerfile``: a file which describes how to set up the image. sbt-native-packager focuses on creating a Docker image which can "just run" the application built by SBT. .. note:: The docker plugin depends on the :ref:`universal-plugin`. Requirements ------------ You need the version 1.10 or higher of the docker console client installed. SBT Native Packager doesn't use the REST API, but instead uses the CLI directly. It is `currently not possible `_ to provide authentication for Docker repositories from within the build. The ``docker`` binary used by the build should already have been configured with the appropriate authentication details. See https://docs.docker.com/engine/reference/commandline/login/ how to login to a Docker registry with username and password. Build ----- .. code-block:: bash sbt docker:publishLocal Required Settings ~~~~~~~~~~~~~~~~~ .. code-block:: scala enablePlugins(DockerPlugin) Spotify java based docker client ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ You can also use the java-based spotify Docker client. Add this to your ``build.sbt`` .. code-block:: scala enablePlugins(DockerSpotifyClientPlugin) and this to your ``plugins.sbt`` .. code-block:: scala libraryDependencies += "com.spotify" % "docker-client" % "8.9.0" The Docker-spotify client is a provided dependency. You have to explicitly add it on your own. It brings a lot of dependencies that could slow your build times. This is the reason the dependency is marked as provided. Configuration ------------- Settings and Tasks inherited from parent plugins can be scoped with ``Docker``. .. code-block:: scala mappings in Docker := mappings.value Settings -------- Informational Settings ~~~~~~~~~~~~~~~~~~~~~~ ``packageName in Docker`` The name of the package for Docker (if different from general name). This will only affect the image name. ``version in Docker`` The version of the package for Docker (if different from general version). Often takes the form ``x.y.z``. ``maintainer in Docker`` The maintainer of the package, recommended by the Dockerfile format. Environment Settings ~~~~~~~~~~~~~~~~~~~~ ``dockerBaseImage`` The image to use as a base for running the application. It should include binaries on the path for ``chown``, ``mkdir``, have a discoverable ``java`` binary, and include the user configured by ``daemonUser`` (``daemon``, by default). ``daemonUser in Docker`` The user to use when executing the application. Files below the install path also have their ownership set to this user. ``dockerExposedPorts`` A list of TCP ports to expose from the Docker image. ``dockerExposedUdpPorts`` A list of UDP ports to expose from the Docker image. ``dockerExposedVolumes`` A list of data volumes to make available in the Docker image. ``dockerLabels`` A map of labels that will be applied to the Docker image. ``dockerEnvVars`` A map of environment variables that will be applied to the Docker image. ``dockerEntrypoint`` Overrides the default entrypoint for docker-specific service discovery tasks before running the application. Defaults to the bash executable script, available at ``bin/