#Docker registry credentials
1 messages ยท Page 1 of 1 (latest)
Hi, the only solution i found is to execute a docker login in the "host machine"
Exactly
OK, it would be nice to get the same functionality as with 0.2 engine, where credentials can be passed directly in the code for each push/pull call. I'm guessing that's planned
I'm in a weird situation where I can't do a "docker login" because my the remote machine(where buildkit is running ) doesn't have docker and neither does the container. Also, this isn't going to be one-time operation for my use-case as my pipeline needs to push to different container repos based off the parameters.
I'm looking at writing ~/docker/config.json in the container to see if that works.
That should work but not universally: that file may reference binary helpersโฆ which will be host specific, for example keychain integration on Docker for Mac
Yeah, it's mostly something I'm in control of.
type DockerConfig struct {
Auths map[string]AuthConfig `json:"auths"`
}
type AuthConfig struct {
Auth string `json:"auth"`
Email string `json:"email"`
}
func NewDockerConfig(username, password, email string) DockerConfig {
authStr := fmt.Sprintf("%s:%s", username, password)
authBytes := []byte(authStr)
encodedAuth := base64.StdEncoding.EncodeToString(authBytes)
return DockerConfig{
Auths: map[string]AuthConfig{
"https://index.docker.io/v1/": {
Auth: encodedAuth,
Email: email,
},
},
}
}
So the pipeline will accept those args
Really it should be a username / secret argument in the API, like in the CUE API
I'm struggling a bit mounting files into container. Is there an example?
I'm on Dagger v0.3.1
Hi, which SDK are you using ?
Go SDK
Give me 5 min ๐ Back with an example ๐
Thank you so much ๐
Oh, there's already this example: https://pkg.go.dev/dagger.io/dagger#example-Container.WithMountedDirectory
In this example, we mount from one container to another. What do you intend to mount ? From countainer to container or from host to container ?
To load a dir from host, then mount it to a container.
There is this example : https://pkg.go.dev/dagger.io/dagger#Host. Then, you can follow with a mountedDirectory of the container, following the first link
Do you think it's helpful or do you still want a full example ?
Let me play around and I'll get back to you . Thank you
Got it to work! Thanks again @muted quarry ๐
From the content of this thread, I realized that docker login must be done outside of dagger.
For example, when publishing a container from github actions to the github container registry, is this the right way to do it?
Or is there a simpler way?
-> github actions sample
jobs:
dagger:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io --username ${{ github.actor }} --password-stdin
- uses: dagger/dagger-for-github@v3
with:
cmds: do check
That's a great solution ๐ ๐