Skip to content

Docker Compose support in Task definitions #324

Open

Description

@oppegard

External services (MySQL, redis, memcached) and the need for an "uber container" to run our test suites are a pain point for the Pivotal Tracker team. For example, our Dockerfile installs the same version of MySQL 5.6.x that we run on pivotaltracker.com to run tests. But, we also have a PCF tile that runs against p-mysql. There seem to be two options for testing both DBs:

  1. Have a second docker image that duplicates the uber image, substituting MariaDB 10.0.x for MySQL 5.6.x.

  2. Jump through hoops of installing both MySQL and MariaDB in the same docker image (using something like http://mysqlsandbox.net/)

We've gone with option 1 for the time being. While an external service such as RDS is an option, I'd rather not be in the business of managing pools of instances and incur the extra network latency.


In an ideal, future-Concourse world, I could mix and match my external services with Docker Compose. As an example, see how Logplex runs their suite on TravisCI:

If they want to run against redis 3.x, it's as simple as changing a line: https://github.com/heroku/logplex/blob/master/docker-compose.yml#L5

An added benefit of Docker Compose is how quickly you get an environment running locally on your workstation. I don't have any of the Logplex dependencies on my MacBook (erlang, redis, etc.). But, my onboarding experience was:

  1. git clone [email protected]:heroku/logplex.git
  2. cd logplex
  3. docker-compose build && docker-compose run test

In the span of 5 minutes I had an erlang test suite running against redis 2.8.

Activity

  1. arnisoph commented on Mar 30, 2016

    @arnisoph

    To run integration tests I need to bootstrap some containers using compose or similar. Is this somehow possible yet?

  2. ahelal commented on Mar 30, 2016

    @ahelal
    Contributor

    Or some thinking like Travis matrix or test kitchen suites. So you can run tests with different combination of things i.e. version, os's, ...

  3. rajatvig commented on Apr 20, 2016

    @rajatvig

    Is this support likely to land anytime soon?

  4. oppegard commented on Apr 20, 2016

    @oppegard
    ContributorAuthor

    It'd be nice to hear from @vito if something like this fits into the conceptual model of Concourse. I haven't thought through what supporting Docker Compose means, only that I want it. For example, I'm not sure if this makes sense as a Resource. To be more clear about what I'd like:

    • A task.yml can specify "service resources" as additional containers that are started along with the main build container. All the containers in a build are networked to each other.
    • Running a one-off build via fly execute still works.

    It seems like a docker-compose.yml would be a good way to describe the desired containers and their networking. It lets teams use Concourse for CI and Docker Compose for local development.

  5. vito commented on Apr 20, 2016

    @vito
    Contributor

    When I have more time I want to play with allowing resources to expose network addresses to builds. That way you could model throwaway databases and services as resources that go away when the build is done. This could be done either with a single Docker Compose resource or with individual postgres/mysql/etc. resources.

  6. Tankanow commented on May 14, 2016

    @Tankanow

    +1
    I vote for as-native-as-possible docker-compose support. One simple sounding, if not implementable, solution is to give tasks access to the worker OS.

  7. royseto commented on May 28, 2016

    @royseto

    Hi, I learned about Concourse this morning and like almost everything I've read about it. Currently we use Jenkins and have a build pipeline that first builds a Docker image, then runs a bunch of test suites against that image in downstream jobs.

    However, I think not being able to link dependent containers into a single Concourse build job will block us from migrating to Concourse. Our app is a Python/Flask app with dependencies on postgres and redis. My build script needs to look something like this:

    docker-compose up
    docker-compose run runtests /tests.sh
    

    where my docker-compose.yml looks something like this:

    runtests:
      image: testbuild
      command: /bin/true
      volumes:
       - ./local.py:/app/config/local.py
       - ./runtests.sh:/runtests.sh
      links:
       - db
       - redis
    db:
      image: my.docker.registry/postgres-dbimage
    redis:
      image: redis
    

    I want to containerize postgres and redis so that we can parallelize our tests and avoid having them step on each other.

    Please let me know if there's a way to accomplish what I am trying to do in Concourse today. Unless I'm missing something, I think I need to make a shell script that does the above and keep calling it from Jenkins for now. Thanks!

  8. vito commented on May 29, 2016

    @vito
    Contributor

    With 1.3 it'll be pretty trivial to run Docker within your task:

    docker daemon &
    docker-compose up
    docker-compose runtests /tests.sh

    This can already be done today, with some workarounds that won't be necessary come 1.3 (e.g. mounting a tmpfs for the Docker graph). You'd also need to run the task with privileged: true, which may also be fixable now that cgroup namespacing is supported in Linux 4.6, though that will have to wait for Garden-runC to support it (/cc @julz).

  9. royseto commented on May 29, 2016

    @royseto

    Thanks @vito. I'll try it out after 1.3 comes out. Do you have a sense for what the performance overhead would be of running Docker containers inside Garden instead of running just Docker or Garden inside the host machine?

  10. julz commented on May 29, 2016

    @julz

    There shouldn't really be much of an impact: containers are just processes (there's no virtualisation going on), the overhead is very very small. The only real impact I can think of is you don't get the shared image cache from the host.

  11. royseto commented on May 29, 2016

    @royseto

    OK, thanks for clarifying that @julz.

  12. seanknox commented on Jun 2, 2016

    @seanknox

    With 1.3 it'll be pretty trivial to run Docker within your task:

    docker daemon &
    docker-compose up
    docker-compose runtests /tests.sh

    This can already be done today, with some workarounds that won't be necessary come 1.3 (e.g. mounting a tmpfs for the Docker graph). You'd also need to run the task with privileged: true, which may also be fixable now that cgroup namespacing is supported in Linux 4.6, though that will have to wait for Garden-runC to support it (/cc @julz).

    @julz @vito, short of docker-compose or concourse v1.3 availability, how does one run tasks that need to run multiple, linked Docker containers? E.g. a Rails app container that also needs additional service containers running like Redis and Postgres.

  13. drnic commented on Jun 5, 2016

    @drnic
    Contributor
  14. Tankanow commented on Jun 8, 2016

    @Tankanow

    @drnic, can you explain this a bit more? How do I integrate this pool of VMs into concourse?

  15. 102 remaining items

  16. AnianZ commented on Apr 17, 2019

    @AnianZ

    This workflow seems to have stopped working with the release of concourse 5.0.0. I can't get the docker-compose in a container setup working any more. It fails with mount: can't find /sys/fs/cgroup in /proc/mounts

    Related post in the forum by another person affected: https://discuss.concourse-ci.org/t/docker-compose-inside-concourse-5-no-longer-working/1232

  17. meAmidos commented on Apr 17, 2019

    @meAmidos

    @AnianZ This might help with the issue: meAmidos/dcind#12

  18. AnianZ commented on Apr 17, 2019

    @AnianZ

    @meAmidos Thank you! That was exactly what I was looking for. Apparently I was watching the wrong version of dcind.

  19. willejs commented on Jan 9, 2020

    @willejs

    @vito is there any future plan or ideas as to how to tackle this?

  20. vito commented on Jan 9, 2020

    @vito
    Contributor

    @willejs The situation hasn't really changed from last time. We have too much on our plate and no one from the community has really tried to tackle this and come up with RFCs/proposals, so until that happens this likely won't go anywhere beyond the current solutions. 🙁

  21. Sispheor commented on Feb 28, 2020

    @Sispheor

    What about something like proposed on Github action?

    services:
      nginx:
        image: nginx
        # Map port 8080 on the Docker host to port 80 on the nginx container
        ports:
          - 8080:80
      redis:
        image: redis
        # Map TCP port 6379 on Docker host to a random free port on the Redis container
        ports:
          - 6379/tcp

    The only thing missing in Action is the ability to use a private registry for the image. But otherwise the implementation seems correct.

  22. lucasmdrs commented on Mar 20, 2020

    @lucasmdrs

    Most CIs use a similar definition to the on above as shown by @Sispheor , TravisCI, CircleCI, Github Actions, GitlabCI... it doesn't seem like a big feature request.

    This makes it harder to run integration tests, that currently only available through some sort of workaround with docker-compose or scripts.

  23. jchesterpivotal commented on Mar 20, 2020

    @jchesterpivotal
    Contributor

    it doesn't seem like a big feature request.

    It doesn't appear to be a big request, no.

    But I think the history of this issue shows that it's a non-trivial change in the current architecture of Concourse.

    It might become easier in future as various architectural refactoring work takes place in order to support Kubernetes as a runtime.

  24. lucasmdrs commented on Mar 21, 2020

    @lucasmdrs

    But I think the history of this issue shows that it's a non-trivial change in the current architecture of Concourse.

    By no means I meant to say it's a trivial change, I apologize if I misspelled and seemed that way.

    But the history of this issue, the date of opening and the large adoption of this feature in other CI tools, shows that it shouldn't be diminished to a Core side-road ("Small features or bug fixes that aren't part of any epic on the roadmap") even less to a Backburner priority lane.

    I'm here to support the request and keep this running, because it's something I would love to see being payed more attention to, as it's something that prevents me to fully adopt the tool.

  25. vito commented on Mar 22, 2020

    @vito
    Contributor

    But the history of this issue, the date of opening and the large adoption of this feature in other CI tools, shows that it shouldn't be diminished to a Core side-road ("Small features or bug fixes that aren't part of any epic on the roadmap") even less to a Backburner priority lane.

    I fully agree with this, and it would be great if someone from the community could help out. As I said before, we have too much on our plate right now to take this on ourselves. :/

    While this is clearly a highly-sought-after feature, there are other highly-sought-after features which are more important right now because the pain felt without them is much worse: namely, support for branches/pull-requests (see the v10 roadmap) and support for runtimes like Kubernetes. Compared to those feature gaps, this issue is a quality-of-life improvement which has existing workarounds and patterns (though they may not be perfect), which means it has lower priority.

    Concourse is a small team and we have to choose our battles. Unfortunately with as many users as we have it's not a matter of simply saying things are high priority, it's a matter of choosing who to disappoint, and hoping the community can pick things up where we can't. 🙁

    Once we get past those big features we can start to take a deeper look at this. But y'all don't have to wait. Progress in the form of technical proposals and proof-of-concepts would really help get the ball rolling. If you want to support this request, that's really the way.

  26. rucciva commented on Jul 17, 2020

    @rucciva

    Hi all, i'm new to concourse, and i have a question, does concourse has some kind of detachable/background task or maybe a persistent resource? Regarding this issue, i'm thinking of running something like docker-compose run --no-deps --use-aliases <service-name> as concourse (detachable) task or maybe (persistent) resources for each of the dependency services before running the final test service. As for the docker daemon, i'm thinking of mapping /var/run/docker.sock to tcp port using something like mutagen so that concourse worker can have access to it.

  27. danihodovic commented on Oct 14, 2020

    @danihodovic
  28. aoldershaw commented on Nov 18, 2020

    @aoldershaw
    Contributor

    I put together an RFC with a proposal for a new services: field for tasks that looks like:

    task: integration-tests
    file: ci/tasks/test.yml
    params:
      POSTGRES_HOST: ((.svc:postgres.host))
      POSTGRES_PORT: ((.svc:postgres.port))
    services:
    - name: postgres
      file: ci/services/postgres.yml

    Would love to hear anyone's thoughts! concourse/rfcs#84

  29. scottillogical commented on Jun 12, 2024

    @scottillogical

    For anyone else who needs this functionality right now, I published the following docker image and example pipeline that is working well for my use case https://github.com/scottillogical/concourse-docker-compose

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions