Update github.com/docker/cli dependency
What does this MR do?
What:
Update to the latest version of github.com/docker/cli
. The only usage
that we have for github.com/docker/cli
is for
helpers/docker/auth
.
Changes:
We are using it for github.com/docker/cli/cli/config/configfile
which
the struct hasn't changed much (check the diff in the vendor directory)
and github.com/docker/cli/cli/config/credentials
which also didn't
change.
The biggest change is that github.com/docker/cli
start using its own
AuthConfig
struct instead of the one from
github.com/moby/moby
and they are identical structs. This requires us to change the import
type from github.com/docker/docker/api/types
to
github.com/docker/cli/cli/config/types
. This was done by Docker in
https://github.com/docker/cli/commit/27b2797f7deb3ca5b7f80371d825113deb1faca1
to remove the dependecy from github.com/moby/moby
.
Why was this MR needed?
This is part of the ongoing effort to support GPUs in GitLab Docker executor which requires us to parse the gpu string, and we need to update this library so we get access to opts/gpus
What's the best way to test this MR?
-
Set up a private project on GitLab.com
-
Push the alpine image to that private project
docker push image to private registry
$ docker login registry.gitlab.com $ docker pull alpine:3.12 3.12: Pulling from library/alpine 801bfaa63ef2: Pull complete Digest: sha256:3c7497bf0c7af93428242d6176e8f7905f2201d8fc5861f45be7a346b5f23436 Status: Downloaded newer image for alpine:3.12 docker.io/library/alpine:3.12 $ docker tag alpine:3.12 registry.gitlab.com/steveazz/playground-private $ docker push registry.gitlab.com/steveazz/playground-private Using default tag: latest The push refers to repository [registry.gitlab.com/steveazz/playground-private] 777b2c648970: Pushed latest: digest: sha256:074d3636ebda6dd446d0d00304c4454f468237fdacf08fb0eeac90bdbfa1bac7 size: 528 $ docker rmi registry.gitlab.com/steveazz/playground-private
Docker executor using auth config from docker client file
-
Start a gitlab-runner whilst still being logged in to
registry.gitlab.com
with the followingconfig.toml
.config.toml
[[runners]] name = "docker" url = "" token = "" executor = "docker" environment = ["FF_NETWORK_PER_BUILD=true"] [runners.docker] tls_verify = false image = "alpine:3.12" privileged = true disable_entrypoint_overwrite = false oom_kill_disable = false disable_cache = false volumes = ["/cache"] shm_size = 0
-
Run the following job using the private image you just pushed Screenshot_2021-01-27_at_13.54.36
-
Run
docker logout registry.gitlab.com
-
Run the same job as before but this time it should fail. Screenshot_2021-01-27_at_14.00.11
Kubernetes executor using
-
Start minikube
minikube start
-
SSH inside of minikube
minikube ssh
-
Loging inside of the registry
docker login registry.gitlab.com
-
Start
gitlab-runner
with kubernetes executor registered -
Run a job with the private image
.gitlab-ci.yml
job: image: registry.gitlab.com/steveazz/playground-private script: - echo "hello"
-
You should get a successful job Screenshot_2021-01-27_at_14.42.03
-
log out inside of the minikube container
docker logout
$ minikube ssh Last login: Wed Jan 27 13:37:38 2021 from 192.168.49.1 docker@minikube:~$ docker logout registry.gitlab.com Removing login credentials for registry.gitlab.com
-
Job should fail Screenshot_2021-01-27_at_14.45.31
Using DOCKER_AUTH_CONFIG
-
Set up the DOCKER_AUTH_CONFIG following https://docs.gitlab.com/ee/ci/docker/using_docker_images.html#determining-your-docker_auth_config-data
-
Run job with the following
.gitlab-ci.yml
(remember to update to your own private image).gitlab-ci.yml
job: image: registry.gitlab.com/steveazz/playground-private script: - echo "hello"