Reputation: 1856
I'm trying to use terraform to implement a very simple configuration based pull of the jenkins image (via docker hub) and then start the image. That's the only thing I want out of this scenario, however with this configuration file...
# Start a container
resource "docker_container" "jenkins" {
name = "jenkins_tf_server"
image = "${docker_image.jenkins.latest}"
command = ["docker run -p 8080:8080 -p 50000:50000 -v /jenkins:/var/jenkins_home -d jenkins"]
}
# Find the latest Ubuntu precise image.
resource "docker_image" "jenkins" {
name = "jenkins"
}
...I'm running into what appears to be two strange situations.
The first one is Terraform, when executing terraform apply
just gets this much done and hangs...
$ terraform apply
docker_image.ubuntu: Refreshing state... (ID: )
docker_image.jenkins: Creating...
latest: "" => "<computed>"
name: "" => "jenkins"
What I thought at first, was because it was downloading an absurd number of jenkins images. Which I checked for after about 15 minutes and found the following using docker images
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu precise e1917e6028b6 6 days ago 138.4 MB
adron/dock-base latest 19322f24adb5 3 weeks ago 417.1 MB
jenkins 1.596.2 b89edf070767 11 months ago 662 MB
jenkins 1.596.1 10929b1bd6c1 12 months ago 662 MB
jenkins 1.596 484633fa05c1 15 months ago 661.7 MB
jenkins 1.595 218ccb377abc 15 months ago 661.7 MB
jenkins 1.594 a0e66c091a65 15 months ago 661.7 MB
jenkins 1.593 d1a051ab9181 15 months ago 661.7 MB
jenkins 1.580.2 a1760aac28b5 15 months ago 661.5 MB
jenkins 1.592 5b1c9d13e15f 15 months ago 661.7 MB
jenkins 1.591 1ed19954eb17 15 months ago 661.7 MB
jenkins 1.590 32a506f5f209 15 months ago 661.7 MB
jenkins 1.589 03046b8487c8 15 months ago 661.7 MB
jenkins 1.588 4808c4dcd370 15 months ago 661.7 MB
jenkins 1.587 46e316ce7c55 15 months ago 661.7 MB
jenkins 1.586 564cf586884f 15 months ago 661.5 MB
jenkins 1.585 095470f5ded4 15 months ago 661.4 MB
jenkins 1.584 4ce45cf2ba35 15 months ago 661.4 MB
jenkins 1.583 c247e6c41208 15 months ago 661.4 MB
jenkins 1.582 1db2820094fc 15 months ago 661.3 MB
jenkins 1.581 89a7e4784544 15 months ago 661.3 MB
jenkins 1.580 96c035d55481 15 months ago 661.3 MB
jenkins 1.580.1 d0580748a09e 15 months ago 661.5 MB
jenkins 1.579 d25e714f32ca 15 months ago 661.3 MB
jenkins 1.578 f27551f8a09e 15 months ago 661.3 MB
jenkins 1.577 08f7a353bb4b 15 months ago 661.3 MB
jenkins 1.576 7a0b44cc2593 15 months ago 661.4 MB
jenkins 1.575 4c4d8a34c3e9 15 months ago 661.4 MB
jenkins 1.574 5594009b4711 15 months ago 661.4 MB
jenkins 1.573 0cb884316533 15 months ago 661.4 MB
jenkins 1.572 be6b4f62a56d 15 months ago 661.3 MB
jenkins 1.571 550ab6938ec7 15 months ago 661.3 MB
jenkins 1.570 5deaae34589f 15 months ago 661.3 MB
jenkins 1.569 a02a7a601061 15 months ago 661.3 MB
jenkins 1.568 d7962fb8c99d 15 months ago 661.3 MB
jenkins 1.567 5076e78cad90 15 months ago 661.6 MB
jenkins 1.566 92a0fc7edfde 15 months ago 661.6 MB
jenkins 1.565 9ac08ed3d170 15 months ago 661.6 MB
jenkins 1.565.3 f32746929b80 15 months ago 661.4 MB
jenkins 1.565.2 7fcc53e58943 15 months ago 661.6 MB
jenkins 1.565.1 f2bf74880f3f 15 months ago 661.6 MB
jenkins 1.564 52abe54f3761 15 months ago 661.6 MB
jenkins 1.563 5dc5fa40c284 15 months ago 661.6 MB
jenkins 1.562 10281098ecaf 15 months ago 661.6 MB
jenkins 1.561 0041414dfbce 15 months ago 661.6 MB
jenkins 1.560 5a0403999187 15 months ago 661.4 MB
jenkins 1.559 f2794ccd4e2d 15 months ago 661 MB
jenkins 1.558 2ef2f3c7344c 15 months ago 660.9 MB
jenkins 1.557 4eca249661ab 15 months ago 660.8 MB
jenkins 1.556 7721817b7521 15 months ago 660.8 MB
jenkins 1.555 30da00a4e34e 15 months ago 660.7 MB
jenkins 1.554.3 37c6c23e2279 15 months ago 661.1 MB
jenkins 1.554.2 eda292ef5358 15 months ago 661.1 MB
jenkins 1.554.1 c00816fce587 15 months ago 660.9 MB
jenkins 1.554 c0ee99758afa 20 months ago 748.8 MB
I've no idea what exactly terraform has gone off and decided to do. Any ideas on how to have it behave and simply start up the image with the docker command in the command
parameter listed above in the terraform file?
Upvotes: 0
Views: 237
Reputation: 136
It looks like a classic shell globbing expansion error.
The bug is in
image = "${docker_image.jenkins.latest}"
Remember that at action time latest
is translated to the most recently added tag.
Either pin the version or have something reap old images.
Upvotes: 2