envbuilder uses Kaniko to build containers. You should follow their instructions to create an authentication configuration.
After you have a configuration that resembles the following:
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "base64-encoded-username-and-password"
}
}
}
base64
encode the JSON and provide it to envbuilder as the
ENVBUILDER_DOCKER_CONFIG_BASE64
environment variable.
Alternatively, the configuration file can be placed in /.envbuilder/config.json
.
The DOCKER_CONFIG
environment variable can be used to define a custom path. The
path must either be the path to a directory containing config.json
or the full
path to the JSON file itself.
[!NOTE] Providing the docker configuration through other means than the
ENVBUILDER_DOCKER_CONFIG_BASE64
environment variable will leave the configuration file in the container filesystem. This may be a security risk.
When running envbuilder
in Kubernetes, you can create an ImagePullSecret
and
pass it into the pod as a volume mount. This example will work for all registries.
# Artifactory example
kubectl create secret docker-registry regcred \
--docker-server=my-artifactory.jfrog.io \
--docker-username=read-only \
--docker-password=secret-pass \
--docker-email=me@example.com \
-n coder
resource "kubernetes_deployment" "example" {
metadata {
namespace = coder
}
spec {
spec {
container {
# Define the volumeMount with the pull credentials
volume_mount {
name = "docker-config-volume"
mount_path = "/.envbuilder/config.json"
sub_path = ".dockerconfigjson"
}
}
# Define the volume which maps to the pull credentials
volume {
name = "docker-config-volume"
secret {
secret_name = "regcred"
}
}
}
}
}
Authenticate with docker login
to generate ~/.docker/config.json
. Encode this file using the base64
command:
$ base64 -w0 ~/.docker/config.json
ewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7CgkJCSJhdXRoIjogImJhc2U2NCBlbmNvZGVkIHRva2VuIgoJCX0KCX0KfQo=
Provide the encoded JSON config to envbuilder:
ENVBUILDER_DOCKER_CONFIG_BASE64=ewoJImF1dGhzIjogewoJCSJodHRwczovL2luZGV4LmRvY2tlci5pby92MS8iOiB7CgkJCSJhdXRoIjogImJhc2U2NCBlbmNvZGVkIHRva2VuIgoJCX0KCX0KfQo=
See here for instructions on running Docker containers inside environments built by Envbuilder.