Expected Outcome
Recreate the default legacy worker or tfe agent docker image without restarting Terraform Enterprise application.
Prerequisites
- Terraform Enterprise v202308-1 or older
- Default legacy worker image
hashicorp/build-worker:now
- Default agent image
hashicorp/tfe-agent:latest
(NOTE:tfe-agent-setup
container must exist)
Use Case
If the default worker image or default tfe-agent image are accidentally deleted while Terraform Enterprise is running due to executing docker system prune
or docker rmi $image
commands, follow the steps below to recreate it without restarting the Terraform Enterprise application. (NOTE: this process does not work for custom legacy worker or tfe-agent images)
Procedure
-
SSH into the Terraform Enterprise host
- To recreate the default legacy worker image(v202308-1 or older):
# Restart the tfe-build-worker container
docker restart tfe-build-worker
# Check the container logs after the restart
docker logs tfe-build-worker
...
{"@level":"info","@message":"Graceful shutdown complete, exiting.","@module":"terraform-build-worker","@timestamp":"2023-06-08T02:16:08.619172Z","git_commit":"94c75da","isolation_type":"docker"}
Building build-worker image from 192.168.78.181:9874/hashicorp-ptfe-base:cd80a4e
Sending build context to Docker daemon 232.4kB
Step 1/3 : FROM 192.168.78.181:9874/hashicorp-ptfe-base:cd80a4e
---> 68c65ebd2b97
Step 2/3 : LABEL com.hashicorp.container-type=per-build
---> Using cache
---> 0c65594190ac
Step 3/3 : ADD ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
---> Using cache
---> b6fff3a5837b
Successfully built b6fff3a5837b
Successfully tagged hashicorp/build-worker:now
# Verify the image is available in Docker
docker images --filter=reference='hashicorp/build-worker:now'
REPOSITORY TAG IMAGE ID CREATED SIZE
hashicorp/build-worker now b6fff3a5837b 11 days ago 316MB - To recreate the default tfe-agent image(v202308-1 or older):
# Start the tfe-agent-setup container
docker start tfe-agent-setup
# Check the logs of the container post-start
docker logs tfe-agent-setup
Building tfe-agent image from hashicorp/tfe-agent:latest
Sending build context to Docker daemon 225.3kB
Step 1/2 : FROM hashicorp/tfe-agent:latest
---> 7b82ae64e913
Step 2/2 : ADD ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
---> 9739e72914e1
Successfully built 9739e72914e1
Successfully tagged hashicorp/tfe-agent:latest
Building tfe-agent image from 192.168.78.179:9874/hashicorp-tfe-agent:e6ada6e
Sending build context to Docker daemon 232.4kB
Step 1/2 : FROM 192.168.78.179:9874/hashicorp-tfe-agent:e6ada6e
---> a75104824090
Step 2/2 : ADD ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
---> e8d7202a1877
Successfully built e8d7202a1877
Successfully tagged hashicorp/tfe-agent:latest
# Verify the image is available in Docker
docker images --filter=reference='hashicorp/tfe-agent:latest'
REPOSITORY TAG IMAGE ID CREATED SIZE
hashicorp/tfe-agent latest e8d7202a1877 2 minutes ago 349MB
- For v202309-1 or later, the Terraform Enterprise application must be restarted.