Gcloud docker push image

Hello,

I’ve recently setup a circleci.yml 2.0. I’m deploying my app on google container engine.

I’ve enabled the - setup_remote_docker option to build my docker image, works great !

I’m manually installing gcloud with :
curl https://dl.google.com/dl/cloudsdk/channels/rapid/install_google_cloud_sdk.bash -o gcloud_install.sh sudo sh gcloud_install.sh --disable-prompts --install-dir="/bin"
and it works fine

But now the command combining both docker and glcoud to push my image on gcloud registry doesn’t work : sudo /bin/google-cloud-sdk/bin/gcloud docker -- push eu.gcr.io/$GCLOUD_PROJECT/app:$CIRCLE_SHA1

This command is executed during the - deploy:

The error is Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I assume this is due to the fact that the docker environment is not connected to the gcloud command, but i’m not sure. Do you have any idea how to fix this ?

Thx !

Well I found the solution : redefine all the Docker parameters in the command :
sudo /bin/google-cloud-sdk/bin/gcloud docker --docker-host=$DOCKER_HOST -- --tlsverify --tlscacert $DOCKER_CERT_PATH/ca.pem --tlscert $DOCKER_CERT_PATH/cert.pem --tlskey $DOCKER_CERT_PATH/key.pem push eu.gcr.io/$GCLOUD_PROJECT/app:$CIRCLE_SHA1

2 Likes

Thanks for posting your solution!

I managed to find the solution to my problem (with traefik and its tcp endpoint, see this gist if you’re interested) thanks to you.

-> Give that man a cookie.