testcontainers-go icon indicating copy to clipboard operation
testcontainers-go copied to clipboard

How to control user account that launches images.

Open naveenchlsn opened this issue 3 years ago • 2 comments

We are seeing test containers throttled by dockerhub while downloading images. We have a docker hub pro account. Hence we were not expecting to get throttled by the docker hub.

Which user does the test containers launch the dockers with? Is it possible to change it?

Thanks, Naveen

naveenchlsn avatar May 21 '21 12:05 naveenchlsn

I had a look at the code and I noticed this https://github.com/testcontainers/testcontainers-go/blob/0d6a586707591c2d74b0e81f3d16a0f3777357d8/container.go#L86

I have to admit I do not remember how it should be used 😕


I had a look around and it looks like this is how credentials should be encoded:

auth := types.AuthConfig{
    Username: cfg.User,
    Password: cfg.Passwd,
}
authBytes, _ := json.Marshal(auth)
authBase64 := base64.URLEncoding.EncodeToString(authBytes)

https://stackoverflow.com/a/42590443/1894196

gianarb avatar May 27 '21 08:05 gianarb

@naveenchlsn does https://github.com/testcontainers/testcontainers-go/issues/324#issuecomment-849426711 resolve your use case?

mdelapenya avatar Sep 15 '22 18:09 mdelapenya

@naveenchlsn I'm closing this issue as there is an open PR (#869) that provides a way to access the docker registry using the credential helpers.

Please reopen it if you do not see it resolved, thanks in advance for your support!

mdelapenya avatar Feb 21 '23 12:02 mdelapenya