kamal
kamal copied to clipboard
Need to be able to set the network=host driver opt to use a local registry
Running a private docker registry on the same host that the build & deploy are running will fail as the buildx container can't reach it.
To get it to work I had to drop the buildx container and recreate it with --driver-opt network=host and then it was able to see my registry, push the image as well as the cache layers.
Not sure if there is another way to get the build container to see the registry, or if kamal needs to allow that option in the builder create command.
+1, I need to set network=my-network since my Traefik is running in my-network, I don't need kamal-proxy.
My temp solution is edit bin/kamal
require "rubygems"
require "bundler/setup"
require "kamal"
patch_version = "2.5.2"
if Kamal::VERSION != patch_version
puts "Kamal::VERSION: #{Kamal::VERSION}, must be #{patch_version} since we are patching it, see #{__FILE__} at line #{__LINE__}"
exit 1
end
Kamal::Commands::App.class_eval do
def run(hostname: nil)
docker :run,
"--detach",
"--restart unless-stopped",
"--name", container_name,
*(["--network", network] unless role.option_args.include?("--network")),
*([ "--hostname", hostname ] if hostname),
"-e", "KAMAL_CONTAINER_NAME=\"#{container_name}\"",
"-e", "KAMAL_VERSION=\"#{config.version}\"",
*role.env_args(host),
*role.logging_args,
*config.volume_args,
*role.asset_volume_args,
*role.label_args,
*role.option_args,
config.absolute_image,
role.cmd
end
end
Kamal::Commands::App::Execution.class_eval do
def execute_in_new_container(*command, interactive: false, detach: false, env:)
docker :run,
("-it" if interactive),
("--detach" if detach),
("--rm" unless detach),
*(["--network", network] unless role.option_args.include?("--network")),
*role&.env_args(host),
*argumentize("--env", env),
*role.logging_args,
*config.volume_args,
*role&.option_args,
config.absolute_image,
*command
end
end
load Gem.bin_path("kamal", "kamal")
@Cluster444 - does using the docker driver work?
builder:
driver: docker
Let me try that out again, I don't have quite the same setup at the moment but I have been meaning to try this again.
Running a local registry is now built in to Kamal via https://github.com/basecamp/kamal/pulls/npezza93