![](/img/trans.png)
[英]On Bitnami's Jenkins Run Docker Commands in Jenkins shell ubuntu
[英]Run Docker commands in Jenkins Shell
我正在嘗試在 Jenkins Shell 中運行 docker 命令
我正在嘗試的命令外殼是
# optional: record current versions of docker apps with each build
docker -v && docker-compose -v && docker-machine -v
# set-up: clean up any previous machine failures
docker-machine stop test || echo "nothing to stop" && \
docker-machine rm test || echo "nothing to remove"
# use docker-machine to create and configure 'test' environment
# add a -D (debug) if having issues
docker-machine create --driver virtualbox test
eval "$(docker-machine env test)"
# use docker-compose to pull and build new images and containers
docker-compose -p jenkins up -d
# optional: list machines, images, and containers
docker-machine ls && docker images && docker ps -a
# wait for containers to fully start before tests fire up
sleep 30
# test services
sh tests.sh $(docker-machine ip test)
# tear down: stop and remove 'test' environment
#docker-machine stop test && docker-machine rm test
有誰知道如何設置 Jenkins 來運行 docker 命令( docker
、 docker-compose
和docker-machine
)?
更新(錯誤信息)
Started by user anonymous
Building in workspace /Users/Shared/Jenkins/Home/jobs/Virtual-Vehicles_Docker_Machine/workspace
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url https://github.com/garystafford/virtual-vehicles-docker.git # timeout=10
Fetching upstream changes from https://github.com/garystafford/virtual-vehicles-docker.git
> git --version # timeout=10
> git -c core.askpass=true fetch --tags --progress https://github.com/garystafford/virtual-vehicles-docker.git +refs/heads/*:refs/remotes/origin/*
> git rev-parse refs/remotes/origin/master^{commit} # timeout=10
> git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
Checking out Revision 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5 (refs/remotes/origin/master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5
> git rev-list 433683c8b9da5272b9f98c9a9653aac5bfb8c0b5 # timeout=10
[workspace] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh
+ docker -v
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 3: docker: command not found
+ docker-machine stop test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 6: docker-machine: command not found
+ echo 'nothing to stop'
nothing to stop
+ docker-machine rm test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 7: docker-machine: command not found
+ echo 'nothing to remove'
nothing to remove
+ docker-machine create --driver virtualbox test
/Users/Shared/Jenkins/tmp/hudson5615310598120649485.sh: line 11: docker-machine: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
命令泊塢窗版本
Client:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 22:37:33 2016
OS/Arch: darwin/amd64
Server:
Version: 1.10.2
API version: 1.22
Go version: go1.5.3
Git commit: c3959b1
Built: Mon Feb 22 22:37:33 2016
OS/Arch: linux/amd64
命令docker-compose -v
docker-compose version 1.6.0, build d99cad6
命令docker-machine -v
docker-machine version 0.6.0, build e27fb87
docker 與 Jenkins 配合良好。
最重要的是,確保在 Jenkins 構建從站上安裝了正確版本的 docker 和 docker-compose(如果需要)。
確保 jenkins 用戶是 Jenkins build slave 上的 docker 組的一部分。
然后就可以照常執行docker命令了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.