[Fixed]-Can circle ci use docker-compose to build the environment

18👍

Yes, using docker-compose in the circle.yml file can be a nice way to run tests because it can mirror ones dev environment very closely. This is a extract from our working tests on a AngularJS project:

---

machine:
  services:
    - docker

dependencies:
  override:
    - docker login -e $DOCKER_EMAIL -u $DOCKER_USER -p $DOCKER_PASS
    - sudo pip install --upgrade docker-compose==1.3.0

test:
  pre:
    - docker-compose pull
    - docker-compose up -d
    - docker-compose run npm install
    - docker-compose run bower install --allow-root --config.interactive=false
  override:
    # grunt runs our karma tests
    - docker-compose run grunt deploy-build compile

Notes:

  • The docker login is only needed if you have private images in docker hub.
  • when we wrote our circle.yml file only docker-compose 1.3 was available. This is probably updated now.
👤Tom

3👍

I haven’t tried this myself but based on the info here https://circleci.com/docs/docker I guess it may work

# circle.yml
machine:
  services:
    - docker

dependencies:
  pre:
    - pip install docker-compose

test:
  pre:
    - docker-compose up -d

3👍

Unfortunately, circleCI by default install old version of Docker 1.9.1 which is not compatible with latest version of docker-compose. In order to get more fresh docker version 1.10.0 you should:

machine:
  pre:
    - curl -sSL https://s3.amazonaws.com/circle-downloads/install-circleci-docker.sh | bash -s -- 1.10.0
    - pip install docker-compose
  services:
    - docker
test:
  pre:
    - docker-compose up -d

Read more: https://discuss.circleci.com/t/docker-1-10-0-is-available-beta/2100

UPD: Native-Docker support on Circle version 2.

Read more information how to switch to new Circle CI version here: https://circleci.com/docs/2.0/migrating-from-1-2/

👤Serge

Leave a comment