sbt-docker
sbt-docker copied to clipboard
Configure dockerPush to use a private registry instead of docker.io
Currently to push to a private repository, I append the registry in frontend of the images name like:
myregistry/project1/target1:version. It will be useful to have an option to configure the registry to push to (that is appended in front of the name at time of push).
This problem could also be solved by allowing multiple tags based upon some settings( for example registry ) and allowing to push only the selected tag(s). For example:
ImageName("localRegistry",s"$dockerRegistry/$project/$name:v${version.value}"),
ImageName("default",s"$project/$name:v${version.value}")
and then allowing
sbt target/dockerBuildAndPush localRegistry
I want to more about the use case for this. When do you need a different name for your image locally and in the registry?
We create multiple images but only some are pushed to the an open registry(lets say docker.io). But each image can/should be pushed to a local private registry. The main difference between naming in the two is that, in the local registry we have detailed versions (dirty versions with hashes), whereas in the global one the versions are simplified.
If there is interest from others on a feature to support this then we could perhaps add it.
But in the mean time it is probably sufficient for you to create a custom task that calls sbtdocker.DockerPush
or that runs the docker push
command directly with the images that you want to push.
Or you could perhaps dynamically add the image names for the open registry to the imageNames in docker
setting when you want to release to your images.
+1
Probably too late, but +1
+1 as well
After re-reading this I'm unsure if this is a problem. It might be as easy to just set the exact names you want the image to be tagged with in the key imageNames in docker
. If not please provide an example to help me understand.
If you want completely custom behavior you can create your own sbt task which can push whatever you want it to push:
import sbtdocker._
val customDockerPush = taskKey[Unit]("My custom docker push task")
customDockerPush := {
val log = Keys.streams.value.log
val dockerPath = (DockerKeys.dockerPath in docker).value
val imageNames = Seq(ImageName("my-org/my-fancy-image:verion"))
DockerPush(dockerPath, imageNames, log)
}
and then just call it sbt customDockerPush
.