Building a docker image in docker executor


#1

Question:

If I am trying to build a custom Dockerfile or use a custom Base image, in both option 1 (the way Circle would normally work, more or less) and option 2 (which seems like Docker in Docker, no?) it looks like I more or less have to run Docker commands against a Docker host, it’s just a matter of whether that host is on the VM or in a container I build. Is that correct?

Is there no way to build or use a custom base image at the high level of a circle.yml build?


Getting Started: Docker Engine
#2

I’m still unclear on this, can I get some clarification?


#3

Hi @eekhss,

from what I understand, if we choose the option 2 to build an image, we can either go:

  • DinD, I guess Jerôme Petazzoni image should be the reference one: https://hub.docker.com/r/jpetazzo/dind/
  • or use a “regular” VM (what is the default distribution ?) that is provided so we can do whatever we want inside it. As the example shows, we should start by installing Docker Engine to be able to build an image. Compose also needs need to be installed if we have to run multi cont itainers applications.

Also, it seems that “machine” executor type refers to “Docker Machine” (VM with Docker Engine installed).
I’m not 100% clear yet on this though as the name of the executor can be confusing (at least for me :slight_smile: ).

Luc


#4

@eekhss Sorry for the delay in answering your question. The reply thread in “Getting Started: Docker Engine” got out of hand.

There is currently no way to build an image at the level of circle.yml.

This is correct.

With the docker executor, a portion of your build is running inside a Docker container. That Docker container is a shared environment, but securely separated from other customer builds. This lets us provision your environment nearly instantly, but comes with the tradeoff that we can’t let you securely build in that environment.

With the machine executor, there is no shared environment at all. This comes with a startup/provision cost. You’re getting your own VM and full control of the Docker engine running inside of it.

The broad use case for the docker executor with setup-docker-engine is for customers with lightweight Docker needs. For instance, they mostly don’t interact with Docker in their test suites, and just need to build an image for deployment.

The use case for the machine executor is for customers who would want to use more advanced Docker features, i.e. shared volumes.

Hope this helps shed some light on the two choices. We’re trying to make the onboarding experience better, so please reply if you have further questions!

@lucj I believe this is correct. The machine executor connects to a remote VM that’s running Docker Engine.


CircleCI 2.0, docker-compose and Docker executor: have my cake and eat it, too?
#5