Sha256: 4a56825b1752277b6990e012e8b49736cb7af23eff8b8b3f29439350fd104970

Contents?: true

Size: 1.68 KB

Versions: 13

Compression:

Stored size: 1.68 KB

Contents

---
title: Docker Image
---

With Kubes, you can use the `docker_image` helper method to select which image to use. It can use images from these sources:

1. CLI Option: The `--image` option specified with the CLI command
2. Kubes Config: Specified by `config.image` in the `.kubes/config.rb`
3. Built Docker Image: The image built from Dockerfile

The CLI option has the highest precedence, and the Built Docker image has the lowest precedence.

## 1. CLI Option

Kubes uses the image from the `--image` option if specified. It's a quick way to override the Docker  image used by Kubes.  Example:

    kubes deploy --image repo/image:tag

When the `--image` option is set, Kubes skips the Docker build phase.

## 2. Kubes Config

If you set the `config.image` in the Kubes config, Kubes will use this prebuilt Docker image instead. Example:

.kubes/config.rb:

```ruby
Kubes.configure do |config|
  config.image = "nginx"
end
```

When `config.image` is set, Kubes skips the Docker build phase.

## 3. Built Docker Image

Kubes can use a Docker image built from your Dockerfile. This is the default behavior of Kubes, as long as the CLI Option and the Kubes Config option is not set.

## Template Example

Here's an example usage of the `docker_image` helper.

.kubes/resources/web/deployment.yaml

```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: web
  labels:
    role: web
spec:
  selector:
    matchLabels:
      role: web
  template:
    metadata:
      labels:
        role: web
    spec:
      containers:
      - name: web
        image: <%= docker_image %>
```

When running `kubes deploy`, Kubes will replace `<%= docker_image %>` with the Docker image from one of the sources described above.

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kubes-0.7.1 docs/_docs/intro/docker-image.md
kubes-0.7.0 docs/_docs/intro/docker-image.md
kubes-0.6.8 docs/_docs/intro/docker-image.md
kubes-0.6.7 docs/_docs/intro/docker-image.md
kubes-0.6.6 docs/_docs/intro/docker-image.md
kubes-0.6.5 docs/_docs/intro/docker-image.md
kubes-0.6.4 docs/_docs/intro/docker-image.md
kubes-0.6.3 docs/_docs/intro/docker-image.md
kubes-0.6.2 docs/_docs/intro/docker-image.md
kubes-0.6.1 docs/_docs/intro/docker-image.md
kubes-0.6.0 docs/_docs/intro/docker-image.md
kubes-0.5.1 docs/_docs/intro/docker-image.md
kubes-0.5.0 docs/_docs/intro/docker-image.md