Building Docker images


#1

I’m trying to catch up on the new circle.yml syntax here. Is the new system able to build Docker images? Here’s a simplified example of how my organization uses CircleCI, in the old YML format:

machine:
  services:
    - docker

dependencies:
  pre:
    # Log into Docker Hub
    - docker login --username="$DOCKER_HUB_USER" --password="$DOCKER_HUB_PASS" --email="$DOCKER_HUB_EMAIL"

  override:
    # Example makefile step. This triggers gulp task runners, installs prerequisites, etc.
    - make

    # Bake the code and the files generated from `make` into an image
    - docker build -t vendor/${CIRCLE_PROJECT_REPONAME,,}:latest .

test:
  override:
    # Test the built image
    - docker-compose -f docker-compose.ci.yml run -T test

deployment:
  master:
    branch: master
    commands:
      # Push the built image back to Docker Hub
      - docker push vendor/image:latest

  tag:
    tag: /v?[0-9]*[.][0-9]*[.][0-9]*[0-9A-Za-z-]*/
    commands:
      # Re-tag and push the built image back to Docker Hub
      - docker tag vendor/${CIRCLE_PROJECT_REPONAME,,}:latest vendor/${CIRCLE_PROJECT_REPONAME,,}:$CIRCLE_TAG
      - docker push vendor/${CIRCLE_PROJECT_REPONAME,,}:$CIRCLE_TAG

I’ve tried a couple tests on the CircleCI 14.04 build image and haven’t had much luck. I haven’t tried downloading and installing my own Docker engine within the container ala Docker-in-Docker because that would require the build container to be run privileged, which I assume is super non-kosher…


#2

I’ve tried to just start the Docker daemon and I run into quite a few issues using CentOS 7 as the base image. Can’t remember exactly what the errors are but it was something to do with filesystem mapping I think. Would be good to know if Circle has solved the Docker in Docker problem, otherwise it becomes non-viable for I imagine quite a few people!


#3

Hi @jamwaffles,

Functionality to build docker images is currently in limited beta release right now.

Please reach out to your Customer Success Manager who helped you with initial 2.0 onboarding.

We are currently onboarding limited number of people to try out our Docker support.


#4

Using the sample from the Google Doc, I’m getting

Build-agent version 0.0.1061-e121eb2 (2016-12-11T02:22:03+0000)
Creating a dedicated  VM
Unexpected environment preparation error: Machine configuration is not found

Also, will this executor be somehow more expensive or are there any other caveats? Is this a layer “below” the docker executor and in a VM that would be started anyways, or is it starting a VM which otherwise is not started?


#5

Hi @jakajancar,

This is unfortunate. We have figured out the reason for the error and your CSM will be reaching out to you with an update.


#6

Hi @anon30319619,
Is there any information when this functionality will be available for all users of 2.0 beta?


#7

:thumbsup: Also curious when this will be available, or if there’s anything I should do in order to be able to test this feature. Thanks!


#8

Hmm, yeah, I was led to believe this functionality was all the new beta 2.0 was about (docker being 1st class citizen). All my repos build, test, and push docker images out to various docker repositories (i.e. aws ecr). Happy to test this on CircleCI if it’s in a more private beta than the current private beta we’re already in.

At the moment, I moved most of my repos to CodeShip’s docker plan, in which you configure a list of containers, both remote and locally-built, and it handles fetching or building (you can also configure for each one whether that image is pulled from cache or not) of those images. The steps config then runs each command against the container of your choosing, and not just the first container like in circleci 2.0, from what I’ve seen.


#9

Hi @ponimas,

Please reach out to your Customer Success Manager who helped you with initial 2.0 onboarding.

We are currently onboarding limited number of people to try out our Docker support.


#10

Hi @petemill ,

Please reach out to your Customer Success Manager who helped you with initial 2.0 onboarding.

We are currently onboarding limited number of people to try out our Docker support.

Happy to get you started.


#11

Hi @nathanleiby ,

Please reach out to your Customer Success Manager who helped you with initial 2.0 onboarding.

We are currently onboarding limited number of people to try out our Docker support.


#12

Hi

I’m building Docker in Docker and works perfectly, but layers are not cached.
Is there any way to cache Docker layers?

I thought that’s the point of the:

- type: setup-docker-engine

Did I miss something?

Also the setup-docker-engine step sometimes takes minutes.


#13

That is not what setup-docker-engine does. We will have support in the future for layer caching, but it’s not complete at this time.


#14

#15

#16

We have updated our documentation to show how to build docker images: https://circleci.com/docs/2.0/building-docker-images/


#17