Sha256: 0bd2efcf3dbb964ae9e50a413c4bc732004848280190db83be79a0975ef5f3b5

Contents?: true

Size: 1.82 KB

Versions: 24

Compression:

Stored size: 1.82 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. You can also set `config.image = false` to simply disable image building.

## 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. You can also set `config.image = false` to simply disable image building.

## 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

24 entries across 24 versions & 1 rubygems

Version Path
kubes-0.9.3 docs/_docs/intro/docker-image.md
kubes-0.9.2 docs/_docs/intro/docker-image.md
kubes-0.9.1 docs/_docs/intro/docker-image.md
kubes-0.9.0 docs/_docs/intro/docker-image.md
kubes-0.8.10 docs/_docs/intro/docker-image.md
kubes-0.8.9 docs/_docs/intro/docker-image.md
kubes-0.8.8 docs/_docs/intro/docker-image.md
kubes-0.8.7 docs/_docs/intro/docker-image.md
kubes-0.8.6 docs/_docs/intro/docker-image.md
kubes-0.8.5 docs/_docs/intro/docker-image.md
kubes-0.8.4 docs/_docs/intro/docker-image.md
kubes-0.8.3 docs/_docs/intro/docker-image.md
kubes-0.8.2 docs/_docs/intro/docker-image.md
kubes-0.8.1 docs/_docs/intro/docker-image.md
kubes-0.8.0 docs/_docs/intro/docker-image.md
kubes-0.7.10 docs/_docs/intro/docker-image.md
kubes-0.7.9 docs/_docs/intro/docker-image.md
kubes-0.7.8 docs/_docs/intro/docker-image.md
kubes-0.7.7 docs/_docs/intro/docker-image.md
kubes-0.7.6 docs/_docs/intro/docker-image.md