[英]Jenkinsfile to start & stop docker containers
Docker 應用程序運行良好,但希望使用 Jenkins 管理 docker 容器,關於在管道中啟動和停止 Z05B6053C41A213EAZ
想尋求有關從頭開始制作 Jenkinsfile 的幫助。 在使用$ docker build -t <imagename>.
並運行應用程序$ docker run -p 8501:8501 <imagename>
,可以在localhost:8501下訪問應用程序。
The git repository is available under this link: https://github.com/nichostst/reliability.git and the Dockerfile
is as shown below:
FROM python:3.7-slim-buster
LABEL maintainer = "Nicholas ST <nichostst@gmail.com>"
LABEL version = "0.1"
WORKDIR /reliability
COPY . /reliability
RUN pip install -r requirements.txt
EXPOSE 8501
CMD ["streamlit", "run", "src/main.py"]
關於jenkinsfile 管道,您有很多方法在管道中使用 docker。
您沒有指定是只想構建 docker 映像還是使用 docker 運行時(在容器中執行項目代碼)。
我會假設你尋求后者。 意思是,在容器中運行您的代碼。
pipeline {
agent {
dockerfile {
filename 'Dockerfile'
dir '.'
args ''
}
}
stages {
stage('prep') {
steps {
echo 'preparing...'
sh '''
# run command within the container
'''
}
}
}
}
並且您始終可以使用sh
運行docker
本機命令
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.