簡體   English   中英

Jenkins - docker:未找到

[英]Jenkins - docker: not found

我是 docker 和 jenkins 的新手,但想看看我是否可以在我的樹莓派上自動部署和運行節點應用程序。 在理想情況下,我希望 Jenkins 從 github 中提取代碼,使用 jenkinsfile 和 dockerfile 構建並運行 docker 圖像(希望這是可能的)。

詹金斯文件

pipeline {
    agent {
        dockerfile true
    }
    environment {
        CI = 'true' 
        HOME = '.'
    }
    stages {
        stage('Install dependencies') {
            steps {
                sh 'npm install'
            }
        }
        stage('Test') { 
            steps {
                sh './scripts/test' 
            }
        }
        stage('Build Container') { 
            steps {
                sh 'docker build -t test-app:${BUILD_NUMBER} . ' 
            }
        }
    }
}

dockerfile

 # Create image based on the official Node image
FROM node:12

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package.json /usr/src/app

# Install dependecies
RUN npm install

# Get all the code needed to run the app
COPY . /usr/src/app

# Expose the port the app runs in
EXPOSE 3000

# Serve the app
CMD ["npm", "start"]

但是,當我嘗試在 jenkins 中運行它時,出現以下錯誤: ../script.sh: docker: not found 這似乎是任何 docker 命令的情況。 我實際上嘗試運行其他一些以“sudo”開頭的命令,它抱怨說sudo: not found 是否缺少步驟,或者我是否嘗試以不正確的方式做某事。 (注意:docker 安裝在樹莓派上。我可以使用 jenkins 用戶登錄並執行 docker 命令。它只是無法通過 web ui 工作)任何建議將不勝感激。

謝謝!

顯然這部分打破了它:

agent {
    dockerfile true
}

當我設置這個時:

agent any

它完成了構建,包括 docker 個命令,沒有任何問題。 我想我只是不明白那件作品是如何運作的。 任何解釋都會有所幫助!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM