How do i deploy from GitLab CI to Google Container Engine instance using Docker?

I am trying to set up automated deployment using a GitLab CI runner to deploy our 4-container app via docker-compose. I can pull the container images down using docker pull commands, but I’m stuck on how to connect to the Google Compute Engine instance in order to run the full docker-compose script.

Typically, from my local machine, I run something like:

  • how to access a webapp deploy folder for deployed war, docker
  • Docker image NGINX not exposing : site cannot be reached
  • How can I get the IP address of a unit started on a machine and use it in another unit with fleet?
  • Docker intermittently failing to start container
  • Remote Docker and volume binding
  • Docker LVM plugin install issues
  • eval $(docker-machine env <machine-instance>)
    docker-compose up -d

    But my .gitlab-ci.yml script doesn’t have docker-machine available.

    1. Do I have to install docker-machine via the script section in my
      .gitlab-ci.yml file?
    2. How do I provision the instance without
      creating a new one every time? Normally, from my local host, I would
      run docker-machine create ... once then just use the eval
      command above to reconnect to the instance. But how would this work
      with CI?

    Here’s a sample of my .gitlab-ci.yml:

    deploy staging:
        image: docker:latest
            - docker:dind
        environment: staging
        stage: deploy
            - docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN
            - docker pull
            - docker pull
            - docker pull
            - docker pull
            - docker-machine ls

  • How do you run an Openshift Docker container as something besides root?
  • Mounting local volumes to remote docker container, Possible?
  • Docker-compose scale up Jetty with NGINX at runtime
  • Unable to Connect to Flask App On Docker From Host [duplicate]
  • jenkins and docker-build-step-plugin configuration
  • Java webapp to Tomcat 8 running in Docker container at localhost
  • 2 Solutions collect form web for “How do i deploy from GitLab CI to Google Container Engine instance using Docker?”

    Not sure what you need docker-machine for in this case. You might want to get rid of it.

    But to go back to your question, the docker image you’re using does not come with neither docker-machine, nor docker-compose :

    So you will need to create a new image (or find an existing one) that comes with those two installed.
    So in the .gitlab-ci.yml, instead of image: docker:latest, it’s going to be something like image: mydocker

    You maybe have to install docker-machine in the GitLab CI Runner to use it with GCE

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.