最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Run Docker Compose inside Jenkins container - Stack Overflow

programmeradmin3浏览0评论

I have installed Docker on my server. Then I run Jenkins container on my server. I want to use Jenkins to deploy some Docker containers using Docker Compose with command docker compose up. The command works when I run it on my host, but does not work when I run from inside Jenkins container.

Error message:

jenkins@10818751582e:/$ docker compose 
docker: 'compose' is not a docker command.
See 'docker --help'

Aside from Docker Compose, Docker is still working fine when I run Docker inside Jenkins container, I was able to build, run and push to registry using Docker command, because I bind the following path to the outside host.

    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /usr/bin/docker:/usr/bin/docker

I have installed Docker on my server. Then I run Jenkins container on my server. I want to use Jenkins to deploy some Docker containers using Docker Compose with command docker compose up. The command works when I run it on my host, but does not work when I run from inside Jenkins container.

Error message:

jenkins@10818751582e:/$ docker compose 
docker: 'compose' is not a docker command.
See 'docker --help'

Aside from Docker Compose, Docker is still working fine when I run Docker inside Jenkins container, I was able to build, run and push to registry using Docker command, because I bind the following path to the outside host.

    volumes:
    - /var/run/docker.sock:/var/run/docker.sock
    - /usr/bin/docker:/usr/bin/docker
Share Improve this question edited Feb 16 at 9:09 halfer 20.4k19 gold badges108 silver badges201 bronze badges asked Feb 16 at 8:35 Minh Quang NguyenMinh Quang Nguyen 3434 silver badges14 bronze badges 1
  • It sounds like you haven't installed the compose plugin in your Jenkins image – Hans Kilian Commented Feb 16 at 8:44
Add a comment  | 

2 Answers 2

Reset to default 1

You have to install docker-compose in your Jenkins machine. Just follow the link https://docs.docker/compose/install/linux/ or

Download and install the Docker Compose standalone, run:

$ curl -SL https://github/docker/compose/releases/download/v2.33.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose

Executable permissions to the standalone binary:

$ chmod +x /usr/local/bin/docker-compose

I don't want to install docker compose into my Jenkins container because I have already install docker compose into my host machine and having two different compose both using the same Docker (Docker was mount into Jenkins container) can result in errors.

A work around solution that worked for me is from within Jenkins container, I ssh into the outside host and then execute the docker compose from the host. Example of command:

ssh <user>@172.17.0.1 'docker compose ...'
发布评论

评论列表(0)

  1. 暂无评论