小编典典

docker-compose:在詹金斯上找不到命令

jenkins

我有一个docker撰写文件

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:

而且我已经配置了詹金斯工作以通过调用另一个外壳文件“ environment.sh”来执行此文件,但是它尝试执行以下错误:

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


阅读 432

收藏
2020-07-25

共1个答案

小编典典

docker-compose$ PATH环境变量中可能不存在您。

首先,您应该删除所有冲突的内容docker-compose-

rm /usr/local/bin/docker-compose

在大多数Linux系统上,以下是我更喜欢安装docker和docker compose的方式-

(以超级用户身份运行命令)

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和docker-compose(v1.17)。

2020-07-25