简体   繁体   中英

docker-compose: command not found on jenkins

I have a docker compose file

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:

And i've configure a jenkins job to execute this file by calling another shell file "environment.sh", but it attempts to execute the following error appears:

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

How can i download and configure docker-compose in jenkins server, also there's no plugin available!, for docker-compose

Probably your docker-compose doesn't exist in your $PATH env variable.

First you should remove any conflicting docker-compose -

rm /usr/local/bin/docker-compose

On most of the Linux systems, below is how I prefer installing docker & docker compose -

(Run commands as 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

Exit the current tty & login back again with $YOUR_USER . This will always install latest docker engine CE & docker-compose(v1.17).

In your environment.sh, do a printenv (or env ) and an echo $PATH .

You can then check if the PATH as seen on the Jenkins agent does include the one for docker-compose .
If not, set it (in your script) before proceeding with the actual docker-compose commands.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM