简体   繁体   中英

Jenkins inside docker on windows 10 pro. Build failing - docker-compose not found

I am trying to setup Jenkins inside docker on Windows 10 pro. I have a python app that successfully runs on powershell command. However, when I run the following command on build execute shell on Jenkins,

docker-compose run app sh -c python manage.py test && flake8

I keep getting the error

/tmp/jenkins7355151386125740055.sh: 2: /tmp/jenkins7355151386125740055.sh: docker-compose: not found Build step 'Execute shell' marked build as failure Finished: FAILURE

What all I tried:

  1. installed docker-compose using pip install docker-compose
  2. set the path of docker-compose in the environment-path variable
  3. created a .env file in the same directory as docker-compose.yml and included the following variable in it COMPOSE_CONVERT_WINDOWS_PATHS=1
  4. My docker-compose.yml is this:
version: "3"

services:
  app:
    build:
      context: .
    ports:
      - "8000:8000"
    volumes:
      - ./app:/app
    command: >
      sh -C "python manage.py runserver 0.0.0.0:8000"

Can anyone help me figure out where am I going wrong and how could I fix the docker-compose not found error?

add env file path to docker-compose file:

version: "3"

services:
  app:
    build:
      context: .
    env_file:
     - {PATH/TO/ENV_FILE}
    ports:
      - "8000:8000"
    volumes:
      - ./app:/app
    command: >
      sh -C "python manage.py runserver 0.0.0.0:8000"

Also if you're building in a container in Jenkins, make sure you have docker-compose setup on Jenkins server (should be a plug-in)

You can try running this at the beginning of your shell script in Jenkins.

curl -L --fail https://github.com/docker/compose/releases/download/1.23.2/run.sh -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

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