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
:
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.
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
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:
- Automatic authentication via Docker Credential Store
- 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
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:
- Pass the
--skip-push
flag tobuild_images
inside yourpipelines
section ofdevspace.yaml
. - Pass the
--skip-push
flag to the DevSpace command you are running, e.g.devspace dev
ordevspace run-pipeline mypipeline
which in turn passes the flag through to everybuild_images
call in the respective pipeline that will be executed. - Set
skipPush: true
within theimages
section of yourdevspace.yaml
as shown in this example:devspace.yamlversion: v2beta1
images:
auth:
image: loftsh/devspace-example-auth
skipPush: true