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:

  • centos 7.3 docker-engine conflicts with docker-common-2
  • Debug Nodejs inside Docker container
  • How can you write a docker daemon that can kick off other docker containers as needed?
  • Run Redis with persistent storage using docker-compose
  • Docker data-only container permissions
  • Rsync (or ssh) to a remote docker container on EC2
  • 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

  • Compiling and running in different containers
  • kibana running on docker: how to save dashboard?
  • change timezone under docker image based on tinycore
  • View Tensorboard on Docker on Google Cloud
  • expose docker containers application port to host on windows using boot2docker
  • How to demonize one image of a docker-compose composition?
  • 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.