Skip to main content
Version: 6.x (Latest)

Push

Unless you are working in a localhost cluster, you will need to push your images to an image registry to be able to use them inside a Kubernetes cluster. DevSpace provides capabilities to push images to any registry if properly configured.

Which Registry?

DevSpace can work with any registry. It retrieves the location of the registry from the image option in devspace.yaml:

devspace.yaml
version: v2beta1
images:
auth:
image: loftsh/devspace-example-auth # Docker Hub
tags:
- dev-latest
api:
image: ghcr.io/loft-sh/devspace-example-api # GitHub Registry
payments:
image: acc123456.dkr.ecr.us-east1.amazonaws.com/devspace-example-payments # AWS ECR
dockerfile: ./payments/Dockerfile
context: ./payments/
tags:
- some-tag
- another-tag

The images in the example above would translate to the following docker push commands (note that we show these docker push commands just for explanatory reasons, DevSpace is actually not running docker push):

# For image auth:
docker push loftsh/devspace-example-auth:dev-latest

# For image api:
docker push ghcr.io/loft-sh/devspace-example-api:[RANDOM_TAG] # No tags were provided, so DevSpace generates a random tag

# For image payments:
docker push acc123456.dkr.ecr.us-east1.amazonaws.com/devspace-example-payments:some-tag
docker push acc123456.dkr.ecr.us-east1.amazonaws.com/devspace-example-payments:another-tag

Local Registry

In many cases you will have push permission to a shared image registry and should proceed to the authentication section. For cases where you do not have a shared image registry, DevSpace can automatically deploy an image registry to your cluster and modify your images to use this local cluster registry.

devspace.yaml
version: v2beta1
images:
no-auth:
image: loftsh/devspace-example-noauth # Rewritten to localhost:XXXXX/loftsh/devspace-example-noauth

The local registry is used as a fallback by default. DevSpace will try to push images to your cluster in this order:

  • Push to authenticated remote registry
  • Use kind load docker-image if using a local KinD cluster
  • Deploy and use local registry

The local registry can be explicity enabled or disabled to change the default behavior. Changing enabled to true will force using the local registry instead of kind load docker-image

devspace.yaml
version: v2beta1
localRegistry:
enabled: false

For complete configuration options for the local registry, see the localRegistry section of the devspace.yaml configuration reference.

Authentication

DevSpace provides two options for authenticating with a registry:

  1. Automatic authentication via Docker Credential Store
  2. Manual registry authentication via pullSecrets

To use the automatic authentication, make sure you sign in to the registry via docker login:

# For Docker Hub:
docker login

# For GitHub:
docker login ghcr.io
Verify Registry Authentication

An easy way to verify if you are successfully authenticated with your registry is to manually run the push command via:

docker push $REGISTRY/$IMAGE:$TAG

If this command works for your registry, image and tag combination, then DevSpace should also be able to push to the registry.

Skip Push

In some cases you may want to skip image building entirely. The most common case is when you are working with a localhost Kubernetes cluster such as Docker Desktop or Minikube.

Automatic Skip Push

DevSpace will automatically try to skip pushing images if it detects that you are working with a localhost Kubernetes cluster. This is only possible if DevSpace is able to build the image with the Docker daemon that powers your Kubernetes cluster (i.e. you are not using kaniko, for example, and the Kubernetes cluster's Docker daemon is reachable for DevSpace).

Manual Skip Push

To manually skip image building, you have the following options:

  1. Pass the --skip-push flag to build_images inside your pipelines section of devspace.yaml.
  2. Pass the --skip-push flag to the DevSpace command you are running, e.g. devspace dev or devspace run-pipeline mypipeline which in turn passes the flag through to every build_images call in the respective pipeline that will be executed.
  3. Set skipPush: true within the images section of your devspace.yaml as shown in this example:
    devspace.yaml
    version: v2beta1
    images:
    auth:
    image: loftsh/devspace-example-auth
    skipPush: true