在bitbucket ssh管道上执行时未找到docker命令

问题描述 投票:0回答:1

[我正在使用bitbucket管道部署我的laravel应用程序,当我将其推送到我的仓库时,它就开始构建,并且可以完美运行,直到docker exec命令将向PHP容器内发送内联命令以执行时,我得到了错误] >

bash: line 3: docker: command not found

这是非常有线的,因为当我直接在同一目录下的同一台服务器上运行命令时,它运行良好,在服务器上安装了docker,并且您可以在execute.sh内部看到。docker-compose运行时没有问题通过管道我得到了错误,请注意pwd以确保命令在正确的目录中执行。

bitbucket-pipelines.yml

image: php:7.3

pipelines:
  branches:
    testing:
      - step:
          name: Deploy to Testing
          deployment: Testing
          services:
            - docker
          caches:
            - composer
          script:
            - apt-get update && apt-get install -y unzip openssh-client
            - curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
            - composer require phpunit/phpunit
            - vendor/bin/phpunit laravel/tests/Unit
            - ssh do.server.net 'bash -s' < execute.sh 

在execute.sh内部,它看起来像这样:

cd /home/docker/docker-laravel
docker-compose build && docker-compose up -d
pwd
docker exec -ti php sh -c "php helpershell.php"
exit

并且bitbucket管道构建结果的输出看起来像这样:

Successfully built 1218483bd067
Successfully tagged docker-laravel_php:latest
Building nginx
Step 1/1 : FROM nginx:latest
 ---> 4733136e5c3c
Successfully built 4733136e5c3c
Successfully tagged docker-laravel_nginx:latest
Creating php ... 
Creating mysql ... 
Creating mysql ... done
Creating php   ... done
Creating nginx ... 
Creating nginx ... done
/home/docker/docker-laravel
bash: line 3: docker: command not found
<< [

我认为发生这种情况的部分原因是因为docker-composedocker是两个单独的命令。仅仅因为一项工作并不意味着它们两者都可以工作。另外,您可能要检查bitbucket-pipelines.yaml文件的缩进,因为yaml可能很挑剔。
bash docker ssh pipeline bitbucket-pipelines
1个回答
0
投票
© www.soinside.com 2019 - 2024. All rights reserved.