I am facing a similar problem, I found this https://reinout.vanrees.org/weblog/2017/10/03/docker-compose-in-jenkins.html but I do not know what is related to.
My problem is test while developing, and also automate the test in Jenkins, and I am using docker-compose to bring up some php scripts AND a mysql server, to run isolated tests (phpunit as of now).
I could think I can achieve this by
- creating a network in docker host (with docker network create)
- create and run a mysql docker attached to that network (with docker run mysql --network=netname --name=mysqlmachine
- run scripts by jenkins specifying --network and refering to mysqlmachineas host.
But this would means I need to setup db data, cleanup db data, and also leave always on the mysqlmachine even when not needed, consuming some ram resource. I can solve last problem with docker start mysqlmachine and docker stop mysqlmachine command in my Jenkinsfile defining the pipeline.
But, again, executing a shell into the docker where jenkins is running I can not find docker command
For me is a viable solution untill I can not find something better
UPDATE:
I will try the https://wiki.jenkins.io/display/JENKINS/Docker+Slaves+Plugin solution, it has almost what I need
UPDATE 08.02:
as suggest by Alexander Zeitler, using
agent {
        docker {
            image 'pdmlab/jenkins-node-docker-agent:6.11.1'
            args '-v /var/run/docker.sock:/var/run/docker.sock'
        }
    }
in Jenkins file allow the use of docker-compose command: docker inside a docker, that is mostly docker near a docker as detailed here: Docker in Docker - volumes not working: Full of files in 1st level container, empty in 2nd tier
But I preferred to use another approach, that does not require to run jenkins in a special way.
The pipeline say:
stage('Test') {
    steps {
        sh './build_docker.sh jenkinstests'
    }
}
and build_docker.sh does:
 jenkinstests)
 docker volume create idealodbconn
 docker run -v idealodbconn:/data --name helper busybox true
 docker cp ./dbconn/db249.json helper:/data
 docker rm helper
 docker-compose -f services/docker-compose-jenkins.yml up \
 --abort-on-container-exit \
 --exit-code-from idealoifapi
 docker-compose -f services/docker-compose-jenkins.yml rm -f
 docker volume rm idealodbconn
 ;;
Also here --abort-on-container-exit say to exit once one container defined into docker-compose-jenkins.yml exits, and --exit-code-from idealoifapi says to take exit code from idealoifapi image.
That is all. Missing part, maybe, is the docker-compose-jenkins.yml use of volume, it is external: true:
volumes:
    idealodbconn:
        external: true