docker-compose:在jenkins上找不到命令

时间:2018-01-27 22:44:29

标签: docker jenkins docker-compose

我有一个泊坞文撰写文件

version: "3"
services:
  mysql:
    image: mysql:latest
    container_name: locations-service-mysql
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_USERNAME: root
      MYSQL_DATABASE: 'locations_schema'
    restart: always
    volumes:
      - mysql_data:/var/lib/mysql:rw

  phpmyadmin:
    image: phpmyadmin/phpmyadmin:latest
    ports:
      - 8181:80
    environment:
      MYSQL_USERNAME: root
      MYSQL_ROOT_PASSWORD: root
      PMA_HOST: mysql
    depends_on:
      - mysql
    links:
      - mysql:mysql


  dropwizard:
    build:
      context : ../locations-service/
    ports:
          - 8080:8080
          - 8081:8081
    depends_on:
          - mysql
    links:
      - mysql:mysql
    restart: always
    container_name: locations-service

volumes:
  mysql_data:

我已经通过调用另一个shell文件" environment.sh"来配置jenkins作业来执行此文件,但它会尝试执行以下错误:

23:51:57 ./environment.sh: line 3: docker-compose: command not found
23:51:57 ./environment.sh: line 4: docker-compose: command not found
23:51:57 ./environment.sh: line 6: docker-compose: command not found
23:51:57  FAILED
23:51:57 
23:51:57 FAILURE: Build failed with an exception.
23:51:57 
23:51:57 * What went wrong:
23:51:57 Execution failed for task ':startDockerEnvironment'.
23:51:57 > Process 'command './environment.sh'' finished with non-zero exit value 127

我如何在jenkins服务器中下载和配置docker-compose,也没有可用的插件!,对于docker-compose

2 个答案:

答案 0 :(得分:2)

您的$ PATH env变量中可能不存在docker-compose {/ 1}}。

首先,您应该删除任何有冲突的docker-compose -

rm /usr/local/bin/docker-compose

在大多数Linux系统上,下面是我更喜欢安装docker& amp; docker撰写 -

(以root身份运行命令)

curl -fsSL get.docker.com -o get-docker.sh
sh get-docker.sh
curl -L https://github.com/docker/compose/releases/download/1.17.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
usermod -aG docker $YOUR_USER
systemctl enable docker

退出当前的tty&使用$YOUR_USER重新登录。这将始终安装最新的docker引擎CE&搬运工-撰写(V1.17)。

答案 1 :(得分:0)

在您的environment.sh中,执行printenv(或env)和回复$PATH

然后,您可以检查Jenkins代理上看到的PATH是否包含docker-compose的内容。
如果没有,请在继续执行实际docker-compose命令之前设置它(在脚本中)。