I use Pipelines for deployment. You need to run the command in the specified folder.

- ssh xfinityphp@185.***.217.*** cd /home/xfinityphp/sms-receive-gateway/app - ssh xfinityphp@185.***.217.*** docker-compose up -d 

Nothing works.

 - ssh xfinityphp@185.***.217.*** cd /home/xfinityphp/sms-receive-gateway/app && docker-compose up -d 

With such a record, too.

What should I do to execute the command in the folder I need?

    2 answers 2

    There are several solutions, the first has already indicated mymedia

     - ssh user@host 'cd /my/work/path; docker-compose up -d' - ssh user@host 'cd /my/work/path && docker-compose up -d' 

    Another, but similar approach is to create / create an intermediate management script (for example, run.sh):

     # ci # ... variables: SSH_WD: /my/work/path script: - cat docker/prod/run.sh | ssh user@host "cat > ${SSH_WD}/run.sh" - ssh user@host "chmod +x ${SSH_WD}/run.sh" - ssh user@host "${SSH_WD}/run.sh" # ... 

    and about run.sh

     #!/bin/bash -xe # здесь можно использовать "любую" логику # управления перезапуском сервисов или приложения в целом cd /my/work/path docker-compose stop #docker-compose down #docker pull my/image:latest docker-compose up -d exit 0 

    Yes, it is more difficult, but it opens extra. management capabilities, plus the management script is stored in git.

    I generate such files automatically during assembly and deployment, it gives the opportunity to make adjustments, add logic, add hooks or checks, use variables, etc. I will say more that the docker-compose.yml also automatically generated. At first it seemed complicated, but it turned out to be very convenient for the team.

      Try:

       - ssh xfinityphp@185.***.217.*** sh -c 'cd /home/xfinityphp/sms-receive-gateway/app && docker-compose up -d' 

      To change the working directory, we start a separate shell process that first goes to the specified folder and then starts the container.

      • Is it possible to implement without cd? - yanodincov February
      • cd is a shell builtin command, it tells the interpreter to execute the chdir system call to change the directory. Then Docker starts, inheriting the working directory from the parent process. I didn’t deal with Docker, but if you believe the documentation , the right combination of -f and -p arguments will solve the situation. - mymedia