Is it possible to deploy without a docker registry? #510
-
|
I have a very fast internet connection (> 1Gbit) and the project I work on is very budget sensitive on the hosting side. After some research, it seems to be trivial to "push" a docker image over ssh: docker save app:1.0 | gzip | DOCKER_HOST=ssh://user@remotehost docker load(source) Is it possible to do something similar with Kamal? |
Beta Was this translation helpful? Give feedback.
Replies: 12 comments 25 replies
-
|
Not sure if this is helpful, but another option is installing a docker registry in the machine you are deploying to: It surely adds some complexity though |
Beta Was this translation helpful? Give feedback.
-
|
This would be nice to have. This was my biggest surprise with Kamal. I was expecting its default to be sans-registry. |
Beta Was this translation helpful? Give feedback.
-
|
Just to add to going the route of managing as an accessory with Kamal. The registry container is pretty flexible with how you want to host it and there's a bunch of documentation around it too. Kamal is great at booting up existing container images and managing the lifecycle of those. https://distribution.github.io/distribution/about/deploying/ You'd want to ensure authentication is in place and preferably it's firewalled appropriately as well, something like this though with the additional ENV options in place for auth. |
Beta Was this translation helpful? Give feedback.
-
|
There is a nice blog post about how to host your own registry here https://nochlin.com/blog/host-your-own-docker-registry-with-kamal-2?utm_source=shortruby&ref=shortruby.com |
Beta Was this translation helpful? Give feedback.
-
|
During the RR2024 event in October 2024, @djmb mentioned it was coming. Any ETA? ... Hate the registries |
Beta Was this translation helpful? Give feedback.
-
|
yeah, it will be nice if the registry option can omitted completely e.g bundling the docker image into a tar file then using rsync to upstream to the server and rebuilding the image on the server. only question is how long that would take. at the moment -- I use rsync for my deploys. |
Beta Was this translation helpful? Give feedback.
-
|
I've stumbled upon this thread while looking into Kamal to replace/unify my current shell script deployments. I have some very simple dockered apps that run on single machines. Those machines do not have access to the repository or its registry. Just as food for thought, here is what I do:
As usual, there are quite some tradeoffs. Most of them check into the "pro" column for me:
|
Beta Was this translation helpful? Give feedback.
-
|
The Kamal team is working towards this. I have noticed them mention this a few times. Here's the branch I found if you want to see in which direction it's going. It's not official so treat it accordingly. |
Beta Was this translation helpful? Give feedback.
-
|
I build https://github.com/psviderski/unregistry to push Docker images directly to remote servers without an external registry. It transfers only the missing layers, making it fast and efficient. The Kamal team may consider integrating it as an option to bypass the registry requirements if they like. cc @dhh |
Beta Was this translation helpful? Give feedback.
-
|
I'd like to share a workaround I've developed for deploying without relying on external registries (Docker Hub, AWS ECR, GitHub Container Registry, etc.). My approach involves running a local registry server and using it to transfer images to the remote server. First, configure the Kamal deployment file (config/deploy.yml): # Credentials for your image host.
registry:
server: localhost:50000
username: dummy
password: dummyThe key points are specifying localhost as the registry server and using dummy values for username and password. Next, start the registry server: docker run -d -p "localhost:50000:5000" --name kamal-local-registry-server \
-v "kamal-local-registry-server-data:/var/lib/registry" \
registry:3Then set up SSH port forwarding to tunnel the remote machine's port 50000 to the local machine's port 50000: ssh -N -R "50000:localhost:50000" user@hostFinally, just run This entire process can be wrapped into a shell script. I can also share the script I'm using if you'd like a reference implementation. bin/deploy#!/bin/bash
set -euo pipefail
IMAGE_NAME="$(yq .image <config/deploy.yml)"
COMMIT_HASH="$(git rev-parse HEAD)"
LOCAL_REGISTRY_SERVER_NAME="kamal-local-registry-server"
LOCAL_REGISTRY_SERVER_PORT=50000
LOCAL_REGISTRY_SERVER_URL="localhost:${LOCAL_REGISTRY_SERVER_PORT}"
SSH_FORWARDER_PIDS=()
SSH_REMOTE_SERVERS=()
SSH_USER="$(yq '.ssh.user // "root"' <config/deploy.yml)"
while read -r server; do
SSH_REMOTE_SERVERS+=("$server")
done < <(yq '.servers.web[]' < config/deploy.yml)
cleanup() {
echo "Cleaning up..."
if docker ps -q -f name="$LOCAL_REGISTRY_SERVER_NAME" | grep -q .; then
echo "Stopping and removing docker container: $LOCAL_REGISTRY_SERVER_NAME"
docker rm -f "$LOCAL_REGISTRY_SERVER_NAME"
fi
for pid in "${SSH_FORWARDER_PIDS[@]}"; do
if kill -0 "$pid" 2>/dev/null; then
echo "Killing SSH forwarder process: $pid"
kill "$pid"
fi
done
}
trap cleanup EXIT INT TERM
# launch local registry server
echo "Launching local registry server..."
docker run -d -p "$LOCAL_REGISTRY_SERVER_PORT:5000" --name $LOCAL_REGISTRY_SERVER_NAME \
-v "${LOCAL_REGISTRY_SERVER_NAME}-data:/var/lib/registry" \
registry:3
# allowing remote servers to access the local registry server
for server in "${SSH_REMOTE_SERVERS[@]}"; do
ssh -N -R "$LOCAL_REGISTRY_SERVER_PORT:$LOCAL_REGISTRY_SERVER_URL" "${SSH_USER}@${server}" &
SSH_FORWARDER_PIDS+=($!)
done
# 1. build image and push it to the local registry server
# 2. pull image on the remote server
# 3. rollout docker container
bin/kamal deploy |
Beta Was this translation helpful? Give feedback.
-
|
Ref. https://github.com/basecamp/kamal/releases/tag/v2.8.0 Use local docker registry to push and pull app images by @npezza93 in #1355 I guess that is the closest way to achieve this, by simply running a local registry (either on your own machine or on the CI server) GPT says I can do something like this: But not sure if someone has guides/tips to do this if we have an Ubuntu 24 CI server for example (where we run kamal deploy from) |
Beta Was this translation helpful? Give feedback.
-
|
This is now possible with: https://kamal-deploy.org/docs/configuration/docker-registry/#using-a-local-container-registry If using Rails 8.1.1 or higher:
|
Beta Was this translation helpful? Give feedback.
This is now possible with: https://kamal-deploy.org/docs/configuration/docker-registry/#using-a-local-container-registry
If using Rails 8.1.1 or higher:
deploy.ymlregistry to be a localhost address as per the above linkkamal registry setup. This will create a local Docker container that is a docker repositorykamal deployas before.