github.com/nilium/gitlab-runner@v12.5.0+incompatible/docs/executors/docker.md (about)

     1  # The Docker executor
     2  
     3  GitLab Runner can use Docker to run jobs on user provided images. This is
     4  possible with the use of **Docker** executor.
     5  
     6  The **Docker** executor when used with GitLab CI, connects to [Docker Engine]
     7  and runs each build in a separate and isolated container using the predefined
     8  image that is [set up in `.gitlab-ci.yml`][yaml] and in accordance in
     9  [`config.toml`][toml].
    10  
    11  That way you can have a simple and reproducible build environment that can also
    12  run on your workstation. The added benefit is that you can test all the
    13  commands that we will explore later from your shell, rather than having to test
    14  them on a dedicated CI server.
    15  
    16  The following table lists what combinations of containers, executors,
    17  and OS are supported.
    18  
    19  | Container Type    | Executor         | OS Type | Supported |
    20  |:-----------------:|:----------------:|:-------:|:---------:|
    21  | Windows Container | `docker`         | Windows | ✗         |
    22  | Windows Container | `docker`         | Linux   | ✗         |
    23  | Windows Container | `docker-windows` | Windows | ✓         |
    24  | Windows Container | `docker-windows` | Linux   | ✗         |
    25  | Linux Containers  | `docker`         | Linux   | ✓         |
    26  | Linux Containers  | `docker`         | Windows | ✓         |
    27  | Linux Containers  | `docker-windows` | Linux   | ✗         |
    28  | Linux Containers  | `docker-windows` | Windows | ✗         |
    29  
    30  NOTE: **Note:**
    31  GitLab Runner uses Docker Engine API
    32  [v1.25](https://docs.docker.com/engine/api/v1.25/) to talk to the Docker
    33  Engine. This means means the
    34  [minimum supported version](https://docs.docker.com/develop/sdk/#api-version-matrix)
    35  of Docker is `1.13.0`.
    36  
    37  ## Using Windows containers
    38  
    39  > [Introduced](https://gitlab.com/groups/gitlab-org/-/epics/535) in 11.11.
    40  
    41  To use Windows containers with the Docker executor, note the following
    42  information about limitations, supported Windows versions, and
    43  configuring a Windows Docker executor.
    44  
    45  ### Limitations
    46  
    47  The following are some limitations of using Windows containers with
    48  Docker executor:
    49  
    50  - Services do not fully work (see
    51    [#4186](https://gitlab.com/gitlab-org/gitlab-runner/issues/4186)).
    52  - Nanoserver cannot be used because it requires PowerShell 6 but GitLab
    53    requires PowerShell 5 (see
    54    [#3291](https://gitlab.com/gitlab-org/gitlab-runner/issues/3291)). See
    55    also the list of [supported Windows
    56    versions](#supported-windows-versions).
    57  - Docker-in-Docker is not supported, since it's [not
    58    supported](https://github.com/docker-library/docker/issues/49) by
    59    Docker itself.
    60  - Interactive web terminals are not supported.
    61  - Host device mounting not supported.
    62  - When mounting a volume directory it has to exist, or Docker will fail
    63    to start the container, see
    64    [#3754](https://gitlab.com/gitlab-org/gitlab-runner/issues/3754) for
    65    additional detail.
    66  - `docker-windows` executor can be run only using GitLab Runner running
    67    on Windows.
    68  - [Linux containers on
    69    Windows](https://docs.microsoft.com/en-us/virtualization/windowscontainers/deploy-containers/linux-containers)
    70    are not supported, since they are still experimental. Read [the
    71    relevant
    72    issue](https://gitlab.com/gitlab-org/gitlab-runner/issues/4373) for
    73    more details.
    74  - Because of a [limitation in
    75    Docker](https://github.com/MicrosoftDocs/Virtualization-Documentation/issues/334),
    76    if the destination path drive letter is not `c:`, paths are not supported for:
    77  
    78    - [`builds_dir`](../configuration/advanced-configuration.html#the-runners-section)
    79    - [`cache_dir`](../configuration/advanced-configuration.html#the-runners-section)
    80    - [`volumes`](../configuration/advanced-configuration.html#volumes-in-the-runnersdocker-section)
    81  
    82    This means values such as `f:\\cache_dir` are not supported, but `f:` is supported.
    83    However, if the destination path is on the `c:` drive, paths are also supported
    84    (for example `c:\\cache_dir`).
    85  
    86  ### Supported Windows versions
    87  
    88  GitLab Runner only supports the following versions of Windows:
    89  
    90  - Windows Server 1809.
    91  - Windows Server 1803.
    92  
    93  You can only run containers based on the same OS version that the Docker
    94  daemon is running on. For example, the following [`Windows Server
    95  Core`](https://hub.docker.com/_/microsoft-windows-servercore) images can
    96  be used:
    97  
    98  - mcr.microsoft.com/windows/servercore:1809
    99  - mcr.microsoft.com/windows/servercore:1809-amd64
   100  - mcr.microsoft.com/windows/servercore:ltsc2019
   101  - mcr.microsoft.com/windows/servercore:1803
   102  
   103  ### Configuring a Windows Docker executor
   104  
   105  NOTE: **Note:**
   106  There is a known issue when a new Runner is registered with `c:\\cache`
   107  as a source directory when passing the `--docker-volumes` or
   108  `DOCKER_VOLUMES` envrionment variable. For more details check
   109  [#4312](https://gitlab.com/gitlab-org/gitlab-runner/issues/4312)
   110  
   111  Below is an example of what the configuration for a simple Docker
   112  executor running Windows
   113  
   114  ```
   115  [[runners]]
   116    name = "windows-docker-2019"
   117    url = "https://gitlab.com/"
   118    token = "xxxxxxx"
   119    executor = "docker-windows"
   120    [runners.docker]
   121      image = "mcr.microsoft.com/windows/servercore:1809_amd64"
   122      volumes = ["c:\\cache"]
   123  ```
   124  
   125  For other configuration options for the Docker executor, see the
   126  [advanced
   127  configuration](../configuration/advanced-configuration.md#the-runnersdocker-section)
   128  section.
   129  
   130  ## Workflow
   131  
   132  The Docker executor divides the job into multiple steps:
   133  
   134  1. **Prepare**: Create and start the [services](https://docs.gitlab.com/ee/ci/yaml/#services).
   135  1. **Pre-job**: Clone, restore [cache](https://docs.gitlab.com/ee/ci/yaml/#cache)
   136     and download [artifacts](https://docs.gitlab.com/ee/ci/yaml/#artifacts) from previous
   137     stages. This is run on a special Docker image.
   138  1. **Job**: User build. This is run on the user-provided Docker image.
   139  1. **Post-job**: Create cache, upload artifacts to GitLab. This is run on
   140     a special Docker Image.
   141  
   142  The special Docker image is based on [Alpine Linux] and contains all the tools
   143  required to run the prepare, pre-job, and post-job steps, like the Git and the
   144  Runner binaries for supporting caching and artifacts. You can find the definition of
   145  this special image [in the official Runner repository][special-build].
   146  
   147  ## The `image` keyword
   148  
   149  The `image` keyword is the name of the Docker image that is present in the
   150  local Docker Engine (list all images with `docker images`) or any image that
   151  can be found at [Docker Hub][hub]. For more information about images and Docker
   152  Hub please read the [Docker Fundamentals][] documentation.
   153  
   154  In short, with `image` we refer to the docker image, which will be used to
   155  create a container on which your build will run.
   156  
   157  If you don't specify the namespace, Docker implies `library` which includes all
   158  [official images](https://hub.docker.com/u/library/). That's why you'll see
   159  many times the `library` part omitted in `.gitlab-ci.yml` and `config.toml`.
   160  For example you can define an image like `image: ruby:2.1`, which is a shortcut
   161  for `image: library/ruby:2.1`.
   162  
   163  Then, for each Docker image there are tags, denoting the version of the image.
   164  These are defined with a colon (`:`) after the image name. For example, for
   165  Ruby you can see the supported tags at <https://hub.docker.com/_/ruby/>. If you
   166  don't specify a tag (like `image: ruby`), `latest` is implied.
   167  
   168  NOTE: **Note:**
   169  The image you choose to run your build in via `image` directive must have a
   170  working shell in its operating system `PATH`. Supported shells are `sh` or
   171  `bash` for Linux, `cmd` or PowerShell for Windows. GitLab Runner cannot
   172  execute a command using the underlying OS system calls (like `exec`).
   173  
   174  ## The `services` keyword
   175  
   176  The `services` keyword defines just another Docker image that is run during
   177  your build and is linked to the Docker image that the `image` keyword defines.
   178  This allows you to access the service image during build time.
   179  
   180  The service image can run any application, but the most common use case is to
   181  run a database container, e.g., `mysql`. It's easier and faster to use an
   182  existing image and run it as an additional container than install `mysql` every
   183  time the project is built.
   184  
   185  You can see some widely used services examples in the relevant documentation of
   186  [CI services examples](https://gitlab.com/gitlab-org/gitlab-ce/tree/master/doc/ci/services/README.md).
   187  
   188  ### How is service linked to the build
   189  
   190  To better understand how the container linking works, read
   191  [Linking containers together](https://docs.docker.com/userguide/dockerlinks/).
   192  
   193  To summarize, if you add `mysql` as service to your application, this image
   194  will then be used to create a container that is linked to the build container.
   195  According to the [workflow](#workflow) this is the first step that is performed
   196  before running the actual builds.
   197  
   198  The service container for MySQL will be accessible under the hostname `mysql`.
   199  So, in order to access your database service you have to connect to the host
   200  named `mysql` instead of a socket or `localhost`.
   201  
   202  ## Define image and services from `.gitlab-ci.yml`
   203  
   204  You can simply define an image that will be used for all jobs and a list of
   205  services that you want to use during build time.
   206  
   207  ```yaml
   208  image: ruby:2.2
   209  
   210  services:
   211    - postgres:9.3
   212  
   213  before_script:
   214    - bundle install
   215  
   216  test:
   217    script:
   218    - bundle exec rake spec
   219  ```
   220  
   221  It is also possible to define different images and services per job:
   222  
   223  ```yaml
   224  before_script:
   225    - bundle install
   226  
   227  test:2.1:
   228    image: ruby:2.1
   229    services:
   230    - postgres:9.3
   231    script:
   232    - bundle exec rake spec
   233  
   234  test:2.2:
   235    image: ruby:2.2
   236    services:
   237    - postgres:9.4
   238    script:
   239    - bundle exec rake spec
   240  ```
   241  
   242  ## Define image and services in `config.toml`
   243  
   244  Look for the `[runners.docker]` section:
   245  
   246  ```
   247  [runners.docker]
   248    image = "ruby:2.1"
   249    services = ["mysql:latest", "postgres:latest"]
   250  ```
   251  
   252  The image and services defined this way will be added to all builds run by
   253  that Runner, so even if you don't define an `image` inside `.gitlab-ci.yml`,
   254  the one defined in `config.toml` will be used.
   255  
   256  ## Define an image from a private Docker registry
   257  
   258  Starting with GitLab Runner 0.6.0, you are able to define images located to
   259  private registries that could also require authentication.
   260  
   261  All you have to do is be explicit on the image definition in `.gitlab-ci.yml`.
   262  
   263  ```yaml
   264  image: my.registry.tld:5000/namepace/image:tag
   265  ```
   266  
   267  In the example above, GitLab Runner will look at `my.registry.tld:5000` for the
   268  image `namespace/image:tag`.
   269  
   270  If the repository is private you need to authenticate your GitLab Runner in the
   271  registry. Read more on [using a private Docker registry][runner-priv-reg].
   272  
   273  ## Accessing the services
   274  
   275  Let's say that you need a Wordpress instance to test some API integration with
   276  your application.
   277  
   278  You can then use for example the [tutum/wordpress](https://hub.docker.com/r/tutum/wordpress/) as a service image in your
   279  `.gitlab-ci.yml`:
   280  
   281  ```yaml
   282  services:
   283  - tutum/wordpress:latest
   284  ```
   285  
   286  When the build is run, `tutum/wordpress` will be started first and you will have
   287  access to it from your build container under the hostname `tutum__wordpress`
   288  and `tutum-wordpress`.
   289  
   290  The GitLab Runner creates two alias hostnames for the service that you can use
   291  alternatively. The aliases are taken from the image name following these rules:
   292  
   293  1. Everything after `:` is stripped.
   294  1. For the first alias, the slash (`/`) is replaced with double underscores (`__`).
   295  1. For the second alias, the slash (`/`) is replaced with a single dash (`-`).
   296  
   297  Using a private service image will strip any port given and apply the rules as
   298  described above. A service `registry.gitlab-wp.com:4999/tutum/wordpress` will
   299  result in hostname `registry.gitlab-wp.com__tutum__wordpress` and
   300  `registry.gitlab-wp.com-tutum-wordpress`.
   301  
   302  ## Configuring services
   303  
   304  Many services accept environment variables which allow you to easily change
   305  database names or set account names depending on the environment.
   306  
   307  GitLab Runner 0.5.0 and up passes all YAML-defined variables to the created
   308  service containers.
   309  
   310  For all possible configuration variables check the documentation of each image
   311  provided in their corresponding Docker hub page.
   312  
   313  NOTE: **Note**:
   314  All variables will be passed to all services containers. It's not designed to
   315  distinguish which variable should go where.
   316  Secure variables are only passed to the build container.
   317  
   318  ## Mounting a directory in RAM
   319  
   320  You can mount a path in RAM using tmpfs. This can speed up the time required to test if there is a lot of I/O related work, such as with databases.
   321  If you use the `tmpfs` and `services_tmpfs` options in the runner configuration, you can specify multiple paths, each with its own options. See the [docker reference](https://docs.docker.com/engine/reference/commandline/run/#mount-tmpfs-tmpfs) for details.
   322  This is an example `config.toml` to mount the data directory for the official Mysql container in RAM.
   323  
   324  ```
   325  [runners.docker]
   326    # For the main container
   327    [runners.docker.tmpfs]
   328        "/var/lib/mysql" = "rw,noexec"
   329  
   330    # For services
   331    [runners.docker.services_tmpfs]
   332        "/var/lib/mysql" = "rw,noexec"
   333  ```
   334  
   335  ## Build directory in service
   336  
   337  Since version 1.5 GitLab Runner mounts a `/builds` directory to all shared services.
   338  
   339  See an issue: <https://gitlab.com/gitlab-org/gitlab-runner/issues/1520>.
   340  
   341  ### PostgreSQL service example
   342  
   343  See the specific documentation for
   344  [using PostgreSQL as a service](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/ci/services/postgres.md).
   345  
   346  ### MySQL service example
   347  
   348  See the specific documentation for
   349  [using MySQL as a service](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/ci/services/mysql.md).
   350  
   351  ### The services health check
   352  
   353  After the service is started, GitLab Runner waits some time for the service to
   354  be responsive. Currently, the Docker executor tries to open a TCP connection to
   355  the first exposed service in the service container.
   356  
   357  You can see how it is implemented by checking this [Go command](https://gitlab.com/gitlab-org/gitlab-runner/blob/master/commands/helpers/health_check.go).
   358  
   359  ## The builds and cache storage
   360  
   361  The Docker executor by default stores all builds in
   362  `/builds/<namespace>/<project-name>` and all caches in `/cache` (inside the
   363  container).
   364  You can overwrite the `/builds` and `/cache` directories by defining the
   365  `builds_dir` and `cache_dir` options under the `[[runners]]` section in
   366  `config.toml`. This will modify where the data are stored inside the container.
   367  
   368  If you modify the `/cache` storage path, you also need to make sure to mark this
   369  directory as persistent by defining it in `volumes = ["/my/cache/"]` under the
   370  `[runners.docker]` section in `config.toml`.
   371  
   372  ### Clearing Docker cache
   373  
   374  GitLab Runner provides the [`clear-docker-cache`](https://gitlab.com/gitlab-org/gitlab-runner/blob/master/packaging/root/usr/share/gitlab-runner/clear-docker-cache)
   375  script to remove containers that can unnecessarily consume disk space.
   376  
   377  Run `clear-docker-cache` regularly (using `cron` once per week, for example),
   378  ensuring a balance is struck between:
   379  
   380  - Maintaining some recent containers in the cache for performance.
   381  - Reclaiming disk space.
   382  
   383  NOTE: **Note:**
   384  `clear-docker-cache` does not clean build or cache volumes.
   385  
   386  ## The persistent storage
   387  
   388  The Docker executor can provide a persistent storage when running the containers.
   389  All directories defined under `volumes =` will be persistent between builds.
   390  
   391  The `volumes` directive supports two types of storage:
   392  
   393  1. `<path>` - **the dynamic storage**. The `<path>` is persistent between subsequent
   394     runs of the same concurrent job for that project. The data is attached to a
   395     custom cache container: `runner-<short-token>-project-<id>-concurrent-<job-id>-cache-<unique-id>`.
   396  1. `<host-path>:<path>[:<mode>]` - **the host-bound storage**. The `<path>` is
   397     bind to `<host-path>` on the host system. The optional `<mode>` can specify
   398     that this storage is read-only or read-write (default).
   399  
   400  ### The persistent storage for builds
   401  
   402  If you make the `/builds` to be **the host-bound storage**, your builds will be stored in:
   403  `/builds/<short-token>/<concurrent-id>/<namespace>/<project-name>`, where:
   404  
   405  - `<short-token>` is a shortened version of the Runner's token (first 8 letters)
   406  - `<concurrent-id>` is a unique number, identifying the local job ID on the
   407    particular Runner in context of the project
   408  
   409  ## The privileged mode
   410  
   411  The Docker executor supports a number of options that allows to fine tune the
   412  build container. One of these options is the [`privileged` mode][privileged].
   413  
   414  ### Use docker-in-docker with privileged mode
   415  
   416  The configured `privileged` flag is passed to the build container and all
   417  services, thus allowing to easily use the docker-in-docker approach.
   418  
   419  First, configure your Runner (config.toml) to run in `privileged` mode:
   420  
   421  ```toml
   422  [[runners]]
   423    executor = "docker"
   424    [runners.docker]
   425      privileged = true
   426  ```
   427  
   428  Then, make your build script (`.gitlab-ci.yml`) to use Docker-in-Docker
   429  container:
   430  
   431  ```bash
   432  image: docker:git
   433  services:
   434  - docker:dind
   435  
   436  build:
   437    script:
   438    - docker build -t my-image .
   439    - docker push my-image
   440  ```
   441  
   442  ## The ENTRYPOINT
   443  
   444  The Docker executor doesn't overwrite the [`ENTRYPOINT` of a Docker image][entry].
   445  
   446  That means that if your image defines the `ENTRYPOINT` and doesn't allow to run
   447  scripts with `CMD`, the image will not work with the Docker executor.
   448  
   449  With the use of `ENTRYPOINT` it is possible to create special Docker image that
   450  would run the build script in a custom environment, or in secure mode.
   451  
   452  You may think of creating a Docker image that uses an `ENTRYPOINT` that doesn't
   453  execute the build script, but does execute a predefined set of commands, for
   454  example to build the docker image from your directory. In that case, you can
   455  run the build container in [privileged mode](#the-privileged-mode), and make
   456  the build environment of the Runner secure.
   457  
   458  Consider the following example:
   459  
   460  1. Create a new Dockerfile:
   461  
   462     ```bash
   463     FROM docker:dind
   464     ADD / /entrypoint.sh
   465     ENTRYPOINT ["/bin/sh", "/entrypoint.sh"]
   466     ```
   467  
   468  1. Create a bash script (`entrypoint.sh`) that will be used as the `ENTRYPOINT`:
   469  
   470     ```bash
   471     #!/bin/sh
   472  
   473     dind docker daemon
   474         --host=unix:///var/run/docker.sock \
   475         --host=tcp://0.0.0.0:2375 \
   476         --storage-driver=vf &
   477  
   478     docker build -t "$BUILD_IMAGE" .
   479     docker push "$BUILD_IMAGE"
   480     ```
   481  
   482  1. Push the image to the Docker registry.
   483  
   484  1. Run Docker executor in `privileged` mode. In `config.toml` define:
   485  
   486     ```toml
   487     [[runners]]
   488       executor = "docker"
   489       [runners.docker]
   490         privileged = true
   491     ```
   492  
   493  1. In your project use the following `.gitlab-ci.yml`:
   494  
   495     ```yaml
   496     variables:
   497       BUILD_IMAGE: my.image
   498     build:
   499       image: my/docker-build:image
   500       script:
   501       - Dummy Script
   502     ```
   503  
   504  This is just one of the examples. With this approach the possibilities are
   505  limitless.
   506  
   507  ## How pull policies work
   508  
   509  When using the `docker` or `docker+machine` executors, you can set the
   510  `pull_policy` parameter which defines how the Runner will work when pulling
   511  Docker images (for both `image` and `services` keywords).
   512  
   513  NOTE: **Note:**
   514  If you don't set any value for the `pull_policy` parameter, then
   515  Runner will use the `always` pull policy as the default value.
   516  
   517  Now let's see how these policies work.
   518  
   519  ### Using the `never` pull policy
   520  
   521  The `never` pull policy disables images pulling completely. If you set the
   522  `pull_policy` parameter of a Runner to `never`, then users will be able
   523  to use only the images that have been manually pulled on the docker host
   524  the Runner runs on.
   525  
   526  If an image cannot be found locally, then the Runner will fail the build
   527  with an error similar to:
   528  
   529  ```
   530  Pulling docker image local_image:latest ...
   531  ERROR: Build failed: Error: image local_image:latest not found
   532  ```
   533  
   534  **When to use this pull policy?**
   535  
   536  This pull policy should be used if you want or need to have a full
   537  control on which images are used by the Runner's users. It is a good choice
   538  for private Runners that are dedicated to a project where only specific images
   539  can be used (not publicly available on any registries).
   540  
   541  **When not to use this pull policy?**
   542  
   543  This pull policy will not work properly with most of [auto-scaled](../configuration/autoscale.md)
   544  Docker executor use cases. Because of how auto-scaling works, the `never`
   545  pull policy may be usable only when using a pre-defined cloud instance
   546  images for chosen cloud provider. The image needs to contain installed
   547  Docker Engine and local copy of used images.
   548  
   549  ### Using the `if-not-present` pull policy
   550  
   551  When the `if-not-present` pull policy is used, the Runner will first check
   552  if the image is present locally. If it is, then the local version of
   553  image will be used. Otherwise, the Runner will try to pull the image.
   554  
   555  **When to use this pull policy?**
   556  
   557  This pull policy is a good choice if you want to use images pulled from
   558  remote registries but you want to reduce time spent on analyzing image
   559  layers difference, when using heavy and rarely updated images.
   560  In that case, you will need once in a while to manually remove the image
   561  from the local Docker Engine store to force the update of the image.
   562  
   563  It is also the good choice if you need to use images that are built
   564  and available only locally, but on the other hand, also need to allow to
   565  pull images from remote registries.
   566  
   567  **When not to use this pull policy?**
   568  
   569  This pull policy should not be used if your builds use images that
   570  are updated frequently and need to be used in most recent versions.
   571  In such situation, the network load reduction created by this policy may
   572  be less worthy than the necessity of the very frequent deletion of local
   573  copies of images.
   574  
   575  This pull policy should also not be used if your Runner can be used by
   576  different users which should not have access to private images used
   577  by each other. Especially do not use this pull policy for shared Runners.
   578  
   579  To understand why the `if-not-present` pull policy creates security issues
   580  when used with private images, read the
   581  [security considerations documentation][secpull].
   582  
   583  ### Using the `always` pull policy
   584  
   585  The `always` pull policy will ensure that the image is **always** pulled.
   586  When `always` is used, the Runner will try to pull the image even if a local
   587  copy is available. If the image is not found, then the build will
   588  fail with an error similar to:
   589  
   590  ```
   591  Pulling docker image registry.tld/my/image:latest ...
   592  ERROR: Build failed: Error: image registry.tld/my/image:latest not found
   593  ```
   594  
   595  > **Note:**
   596  For versions prior to `v1.8`, when using the `always` pull policy, it could
   597  fall back to local copy of an image and print a warning:
   598  >
   599  > ```
   600  > Pulling docker image registry.tld/my/image:latest ...
   601  > WARNING: Cannot pull the latest version of image registry.tld/my/image:latest : Error: image registry.tld/my/image:latest not found
   602  > WARNING: Locally found image will be used instead.
   603  > ```
   604  >
   605  That is changed in version `v1.8`. To understand why we changed this and
   606  how incorrect usage of may be revealed please look into issue
   607  [#1905](https://gitlab.com/gitlab-org/gitlab-runner/issues/1905).
   608  
   609  **When to use this pull policy?**
   610  
   611  This pull policy should be used if your Runner is publicly available
   612  and configured as a shared Runner in your GitLab instance. It is the
   613  only pull policy that can be considered as secure when the Runner will
   614  be used with private images.
   615  
   616  This is also a good choice if you want to force users to always use
   617  the newest images.
   618  
   619  Also, this will be the best solution for an [auto-scaled](../configuration/autoscale.md)
   620  configuration of the Runner.
   621  
   622  **When not to use this pull policy?**
   623  
   624  This pull policy will definitely not work if you need to use locally
   625  stored images. In this case, the Runner will skip the local copy of the image
   626  and try to pull it from the remote registry. If the image was build locally
   627  and doesn't exist in any public registry (and especially in the default
   628  Docker registry), the build will fail with:
   629  
   630  ```
   631  Pulling docker image local_image:latest ...
   632  ERROR: Build failed: Error: image local_image:latest not found
   633  ```
   634  
   635  ## Docker vs Docker-SSH (and Docker+Machine vs Docker-SSH+Machine)
   636  
   637  NOTE: **Note**:
   638  Starting with GitLab Runner 10.0, both docker-ssh and docker-ssh+machine executors
   639  are **deprecated** and will be removed in one of the upcoming releases.
   640  
   641  We provided a support for a special type of Docker executor, namely Docker-SSH
   642  (and the autoscaled version: Docker-SSH+Machine). Docker-SSH uses the same logic
   643  as the Docker executor, but instead of executing the script directly, it uses an
   644  SSH client to connect to the build container.
   645  
   646  Docker-ssh then connects to the SSH server that is running inside the container
   647  using its internal IP.
   648  
   649  This executor is no longer maintained and will be removed in the near future.
   650  
   651  [Docker Fundamentals]: https://docs.docker.com/engine/understanding-docker/
   652  [docker engine]: https://www.docker.com/products/container-runtime
   653  [hub]: https://hub.docker.com/
   654  [linking-containers]: https://docs.docker.com/engine/userguide/networking/default_network/dockerlinks/
   655  [postgres-hub]: https://registry.hub.docker.com/u/library/postgres/
   656  [mysql-hub]: https://registry.hub.docker.com/u/library/mysql/
   657  [runner-priv-reg]: ../configuration/advanced-configuration.md#using-a-private-container-registry
   658  [yaml]: http://doc.gitlab.com/ce/ci/yaml/README.html
   659  [toml]: ../commands/README.md#configuration-file
   660  [alpine linux]: https://alpinelinux.org/
   661  [special-build]: https://gitlab.com/gitlab-org/gitlab-runner/tree/master/dockerfiles/build
   662  [privileged]: https://docs.docker.com/engine/reference/run/#runtime-privilege-and-linux-capabilities
   663  [entry]: https://docs.docker.com/engine/reference/run/#entrypoint-default-command-to-execute-at-runtime
   664  [secpull]: ../security/index.md#usage-of-private-docker-images-with-if-not-present-pull-policy