terraform-provider-docker
terraform-provider-docker copied to clipboard
Changes to the docker_image resource end in the Error: failed to solve with frontend dockerfile.v0: failed to read dockerfile: Error processing tar file(exit status 1): unexpected EOF
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Terraform (and docker Provider) Version
Terraform v1.3.7 on windows_386
- provider registry.terraform.io/kreuzwerker/docker v2.25.0
Docker Desktop Version
docker version Client: Cloud integration: v1.0.29 Version: 20.10.21 API version: 1.41 Go version: go1.18.7 Git commit: baeda1f Built: Tue Oct 25 18:08:16 2022 OS/Arch: windows/amd64 Context: default Experimental: true
Server: Docker Desktop 4.15.0 (93002) Engine: Version: 20.10.21 API version: 1.41 (minimum version 1.12) Go version: go1.18.7 Git commit: 3056208 Built: Tue Oct 25 18:00:19 2022 OS/Arch: linux/amd64 Experimental: false containerd: Version: 1.6.10 GitCommit: 770bd0108c32f3fb5c73ae1264f7e503fe7b2661 runc: Version: 1.1.4 GitCommit: v1.1.4-0-g5fd4c4d docker-init: Version: 0.19.0 GitCommit: de40ad0
Affected Resource(s)
docker_image
Debug Output
docker_image.zoo: Creating... ╷ │ Error: failed to solve with frontend dockerfile.v0: failed to read dockerfile: Error processing tar file(exit status 1): unexpected EOF │ │ │ │ with docker_image.zoo, │ on main.tf line 14, in resource "docker_image" "zoo": │ 14: resource "docker_image" "zoo" { │ ╵
Expected Behaviour
No Error and rebuild docker image.
Actual Behaviour
A change to main.tf triggers a Docker image build and ends with an error message.
Steps to Reproduce
Dockerfile
FROM ubuntu
RUN echo "while true; do date; sleep 10; done" > /start.sh && chmod 775 /start.sh
CMD ["/bin/sh", "-c", "/start.sh"]
terraform main.tf
terraform {
required_providers {
docker = {
source = "kreuzwerker/docker"
version = ">= 2.25.0"
}
}
}
provider "docker" {
}
resource "docker_image" "zoo" {
name = "zoo"
keep_locally = true
build {
context = "${path.cwd}/."
label = {
author : "test"
}
}
}
resource "docker_container" "zoo" {
image = docker_image.zoo.latest
name = "zoo"
}
terraform init
Initializing the backend...
Initializing provider plugins...
- Finding kreuzwerker/docker versions matching ">= 2.25.0"...
- Installing kreuzwerker/docker v2.25.0...
- Installed kreuzwerker/docker v2.25.0 (self-signed, key ID BD080C4571C6104C)
...
Terraform has been successfully initialized!
...
- first
terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
+ create
Terraform will perform the following actions:
# docker_container.zoo will be created
+ resource "docker_container" "zoo" {
+ attach = false
+ bridge = (known after apply)
+ command = (known after apply)
+ container_logs = (known after apply)
+ container_read_refresh_timeout_milliseconds = 15000
+ entrypoint = (known after apply)
+ env = (known after apply)
+ exit_code = (known after apply)
+ gateway = (known after apply)
+ hostname = (known after apply)
+ id = (known after apply)
+ image = (known after apply)
+ init = (known after apply)
+ ip_address = (known after apply)
+ ip_prefix_length = (known after apply)
+ ipc_mode = (known after apply)
+ log_driver = (known after apply)
+ logs = false
+ must_run = true
+ name = "zoo"
+ network_data = (known after apply)
+ read_only = false
+ remove_volumes = true
+ restart = "no"
+ rm = false
+ runtime = (known after apply)
+ security_opts = (known after apply)
+ shm_size = (known after apply)
+ start = true
+ stdin_open = false
+ stop_signal = (known after apply)
+ stop_timeout = (known after apply)
+ tty = false
+ wait = false
+ wait_timeout = 60
+ healthcheck {
+ interval = (known after apply)
+ retries = (known after apply)
+ start_period = (known after apply)
+ test = (known after apply)
+ timeout = (known after apply)
}
+ labels {
+ label = (known after apply)
+ value = (known after apply)
}
}
# docker_image.zoo will be created
+ resource "docker_image" "zoo" {
+ id = (known after apply)
+ image_id = (known after apply)
+ keep_locally = true
+ latest = (known after apply)
+ name = "zoo"
+ output = (known after apply)
+ repo_digest = (known after apply)
+ build {
+ cache_from = []
+ context = "C:/Users/.../ubuntu/."
+ dockerfile = "Dockerfile"
+ extra_hosts = []
+ label = {
+ "author" = "test"
}
+ remove = true
+ security_opt = []
+ tag = []
}
}
Plan: 2 to add, 0 to change, 0 to destroy.
╷
│ Warning: Deprecated attribute
│
│ on main.tf line 25, in resource "docker_container" "zoo":
│ 25: image = docker_image.zoo.latest
│
│ The attribute "latest" is deprecated. Refer to the provider documentation for details.
│
│ (and one more similar warning elsewhere)
╵
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
docker_image.zoo: Creating...
docker_image.zoo: Creation complete after 2s [id=sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6zoo]
docker_container.zoo: Creating...
docker_container.zoo: Creation complete after 1s [id=403260e5d04c88addc7216881380e6ef3ad8f06b8c68582f0a93eb63cd439759]
╷
│ Warning: Deprecated attribute
│
│ on main.tf line 25, in resource "docker_container" "zoo":
│ 25: image = docker_image.zoo.latest
│
│ The attribute "latest" is deprecated. Refer to the provider documentation for details.
│
│ (and one more similar warning elsewhere)
╵
Apply complete! Resources: 2 added, 0 changed, 0 destroyed.
- Change the
main.tfe.g.docker_image.build.label.author - second
terraform apply
docker_image.zoo: Refreshing state... [id=sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6zoo]
docker_container.zoo: Refreshing state... [id=403260e5d04c88addc7216881380e6ef3ad8f06b8c68582f0a93eb63cd439759]
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement
Terraform will perform the following actions:
# docker_container.zoo must be replaced
-/+ resource "docker_container" "zoo" {
+ bridge = (known after apply)
~ command = [
- "/bin/sh",
- "-c",
- "/start.sh",
] -> (known after apply)
+ container_logs = (known after apply)
- cpu_shares = 0 -> null
- dns = [] -> null
- dns_opts = [] -> null
- dns_search = [] -> null
~ entrypoint = [] -> (known after apply)
~ env = [] -> (known after apply)
+ exit_code = (known after apply)
~ gateway = "192.168.0.1" -> (known after apply)
- group_add = [] -> null
~ hostname = "403260e5d04c" -> (known after apply)
~ id = "403260e5d04c88addc7216881380e6ef3ad8f06b8c68582f0a93eb63cd439759" -> (known after apply)
~ image = "sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6" -> (known after apply) # forces replacement
~ init = false -> (known after apply)
~ ip_address = "192.168.0.3" -> (known after apply)
~ ip_prefix_length = 24 -> (known after apply)
~ ipc_mode = "private" -> (known after apply)
- links = [] -> null
~ log_driver = "json-file" -> (known after apply)
- log_opts = {} -> null
- max_retry_count = 0 -> null
- memory = 0 -> null
- memory_swap = 0 -> null
name = "zoo"
~ network_data = [
- {
- gateway = "192.168.0.1"
- global_ipv6_address = ""
- global_ipv6_prefix_length = 0
- ip_address = "192.168.0.3"
- ip_prefix_length = 24
- ipv6_gateway = ""
- network_name = "bridge"
},
] -> (known after apply)
- network_mode = "default" -> null
- privileged = false -> null
- publish_all_ports = false -> null
~ runtime = "runc" -> (known after apply)
~ security_opts = [] -> (known after apply)
~ shm_size = 64 -> (known after apply)
+ stop_signal = (known after apply)
~ stop_timeout = 0 -> (known after apply)
- storage_opts = {} -> null
- sysctls = {} -> null
- tmpfs = {} -> null
# (13 unchanged attributes hidden)
+ healthcheck {
+ interval = (known after apply)
+ retries = (known after apply)
+ start_period = (known after apply)
+ test = (known after apply)
+ timeout = (known after apply)
}
+ labels {
+ label = (known after apply)
+ value = (known after apply)
}
}
# docker_image.zoo must be replaced
-/+ resource "docker_image" "zoo" {
~ id = "sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6zoo" -> (known after apply)
~ image_id = "sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6" -> (known after apply)
~ latest = "sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6" -> (known after apply)
name = "zoo"
+ output = (known after apply)
+ repo_digest = (known after apply)
# (1 unchanged attribute hidden)
- build { # forces replacement
- build_arg = {} -> null
- build_args = {} -> null
- cache_from = [] -> null
- context = "C:/Users/.../ubuntu/." -> null
- cpu_period = 0 -> null
- cpu_quota = 0 -> null
- cpu_shares = 0 -> null
- dockerfile = "Dockerfile" -> null
- extra_hosts = [] -> null
- force_remove = false -> null
- label = {
- "author" = "test"
} -> null
- labels = {} -> null
- memory = 0 -> null
- memory_swap = 0 -> null
- no_cache = false -> null
- pull_parent = false -> null
- remove = true -> null
- security_opt = [] -> null
- shm_size = 0 -> null
- squash = false -> null
- suppress_output = false -> null
- tag = [] -> null
}
+ build { # forces replacement
+ cache_from = []
+ context = "C:/Users/.../ubuntu/."
+ dockerfile = "Dockerfile"
+ extra_hosts = []
+ label = {
+ "author" = "test2"
}
+ remove = true
+ security_opt = []
+ tag = []
}
}
Plan: 2 to add, 0 to change, 2 to destroy.
╷
│ Warning: Deprecated attribute
│
│ on main.tf line 25, in resource "docker_container" "zoo":
│ 25: image = docker_image.zoo.latest
│
│ The attribute "latest" is deprecated. Refer to the provider documentation for details.
│
│ (and one more similar warning elsewhere)
╵
Do you want to perform these actions?
Terraform will perform the actions described above.
Only 'yes' will be accepted to approve.
Enter a value: yes
docker_container.zoo: Destroying... [id=403260e5d04c88addc7216881380e6ef3ad8f06b8c68582f0a93eb63cd439759]
docker_container.zoo: Destruction complete after 1s
docker_image.zoo: Destroying... [id=sha256:ddfc623f4b0fcd93eb5b4f1dfc4d454b4072ed066905f60b6ec2829d8e2f9cf6zoo]
docker_image.zoo: Destruction complete after 0s
docker_image.zoo: Creating...
╷
│ Error: failed to solve with frontend dockerfile.v0: failed to read dockerfile: Error processing tar file(exit status 1): unexpected EOF
│
│
│
│ with docker_image.zoo,
│ on main.tf line 13, in resource "docker_image" "zoo":
│ 13: resource "docker_image" "zoo" {
│
╵
All subsequent terraform apply will give the same result.
By deleting the terraform.tfstate file, you can start over with the same result.
Important Factoids
- Docker Desktop Windows configuration
{
"builder": {
"gc": {
"defaultKeepStorage": "20GB",
"enabled": true
}
},
"experimental": false,
"features": {
"buildkit": false
}
}
- enable or disable the buildkit has no effect
- enable or disable of firewall and virus scanner has no effect
References
nothing really comparable found on the net
- #0000