Jenkins docker-运行容器、执行shell脚本等
我正在试着运行Jenkins管道中的docker容器 我的文件中有以下内容:Jenkins docker-运行容器、执行shell脚本等,docker,jenkins,jenkins-pipeline,jenkins-docker,Docker,Jenkins,Jenkins Pipeline,Jenkins Docker,我正在试着运行Jenkins管道中的docker容器 我的文件中有以下内容: stage('test') { steps { script { parallel ( "gatling" : { sh 'bash ./test-gatling.sh' }, "python" : { sh 'bash ./test-python.sh' }) }
stage('test') {
steps {
script {
parallel (
"gatling" : {
sh 'bash ./test-gatling.sh'
},
"python" : {
sh 'bash ./test-python.sh'
})
}
}
}
在测试gatling.sh
中,我有:
#!/bin/bash
docker cp RecordedSimulation.scala denvazh/gatling:/RecordedSimulation.scala
docker run -it -m denvazh/gatling /bin/bash
ls
./gatling.sh
ls命令仅用于测试,但在执行时,它会列出github存储库中的文件和文件夹,而不是denvazh/gatling
容器中的文件。为什么呢?我想,docker run-it[…]
命令会打开容器,以便在其中运行命令
================
另外,我如何运行一个容器并让它运行,而不在其中执行任何命令?(在Jenkins管道ofc中)
我想运行:
docker run-d-p8080:8080-t[my_container]
并在端口8080上访问它。我该怎么做…?如果有人有相同或类似的问题,以下是答案:
docker exec[name of container]
命令,要在容器内运行任何终端命令,请添加/bin/bash-c“[command]”
--net=host
参数运行它如果有人有相同或类似的问题,以下是答案:
docker exec[name of container]
命令,要在容器内运行任何终端命令,请添加/bin/bash-c“[command]”
--net=host
参数运行它问题出在bash脚本中。在docker中只执行“/bin/bash”命令。下面的行不会在您刚才调用的bin/bash中自动执行。我经常在Jenkins文件中有多个
docker compose运行…一些命令…
。问题在于您的bash脚本。在docker中只执行“/bin/bash”命令。下面的行不会在您刚才调用的bin/bash中自动执行。我经常在我的文件中有多个docker compose运行…一些命令…
。