Building docker images in 2.0


Hello there. I’m trying to get a hang of CircleCI 2.0 and don’t know what approach should I take and to wrap things I do in 1.0 to 2.0

So, basically. I have a php project and docker-compose file.
What I do in 1.0 build container:

  • run app init php script, run composer install
  • build docker image for application
  • run docker-compose file which spawns databases and runs tests inside an app image.
  • push image on success

What should I do in 2.0? Use docker-in-docker container to wrap all that again?
Or should I write a lot of stuff in 2.0 to declare all the containers I use in docker-compose?


I would use docker-compose. Since you’re already using it, let’s take the easy route. Just build a Docker image to run your commands in, use setup-docker-engine, and then docker-compose up.

The great thing about docker-compose is the consistency. You might as well hold onto it :slight_smile:


Thanks. That’s exactly what I want. Because container launch process is basically the same across developer machine/ci/production with some minor differences in service discovery mechanisms.

A little feedback:
This whole process complicates things in comparison CircleCI 1.0. Because I basically had all the stuff I need in a build agent and I just run some commands for application testing and building a clean app image without unnecessary dependencies.
Here, in 2.0, I need to build an image myself so I can run a containers inside a container inside a build agent.
And setup_docker_engine takes an extra minute to initialise. And it says it basically runs VM inside build agent. So it’s no different from executorType: machine.
And then, I don’t get to use all the things with spinning up multiple containers defined in circle.yml


Totally agree. If you have a dockerized app that builds a container and runs tests inside it, it’s very complicated to set up in 2.0. Additionally, build artifacts can’t be shared from your container back to the job space. So we lose that feature as well.

Am I misunderstanding here?


That is all true for the docker executor but not true for the machine executor.


Got it - makes sense. Didn’t realize that was an option. Thanks!


Will artifact sharing ever be possible with the docker executor?


Yes, soon. It will be available with Workflows. As far as I understand, this is being actively developed.