Reputation: 1650
I have a pipeline script where I'm trying to link several containers together (a liberty container, oracle container and a maven jdk container).
First I create the oracle container:
db = docker.build('oracle', 'docker/oracle').run("-p 49160:22 -p 49161:1521")
Then link it to my liberty container which seems to work ok:
wlp = docker.build('liberty', 'docker/liberty').run("-p 9080:9080 --link=${db.id}:oracle")
But when I try to link it to the maven one:
mvn.inside('-v $M2_REPO:/m2repo --link=${db.id}:oracle ') {
I get the following error in jenkins:
Failure: java.io.IOException: Failed to run image 'maven:3.3.9-jdk-8'. Error: docker: Error response from daemon: Could not get container for ${db.id}. See '/usr/bin/docker-current run --help'.
Could this be related to the fact that it's using the inside
call rather than run
?
Upvotes: 2
Views: 2489
Reputation: 7940
Your variable ${db.id}
is not replaced (or groovy speak: interpolated) inside the Pipeline DSL script because you put are using single quotes.
Adjust your command to use double quotes instead:
mvn.inside("-v \$M2_REPO:/m2repo --link=${db.id}:oracle") {
I suppose you don't want to have $M2_REPO
interpolated, thus it is escaped by prepending a \
.
Upvotes: 3
Reputation: 2942
I do not know what language it is but docker build looks for a file "Dockerfile" in current directory. So
docker.build('oracle', 'docker/oracle')
has some problem because its already build image with tag docker/oracle
you just have to run this image not to build.
Upvotes: 0