Using variables on docker ubuntu

I’m trying to set the ipv4 to a docker ubuntu source in a packer source template…

I’m defining ipv4 as follows just above the ubuntu source line.

variable "ipv4" {
  type    = string
  default = "10.0.0.127"
 }
source "docker" "ubuntu" {
  commit = true
  pull = false
  run_command = ["-d", "-i", "-t", "--entrypoint=/bin/bash", "--ip={{.ipv4}}", "--network=Cluster", "--", "{{.Image}}"]
}

using {{.ipv4}} works when using packer validate .
However, it still fails …

/usr/local/bin/packer build -only='web_nfs_stage_1.docker.ubuntu' -var 'ipv4=10.0.0.2' .
web_nfs_stage_1.docker.ubuntu: output will be in this color.

==> web_nfs_stage_1.docker.ubuntu: Creating a temporary directory for sharing data...
==> web_nfs_stage_1.docker.ubuntu: Starting docker container...
==> web_nfs_stage_1.docker.ubuntu: Error running container: template: root:1:7: executing "root" at <.ipv4>: can't evaluate field ipv4 in type *docker.startContainerTemplate
Build 'web_nfs_stage_1.docker.ubuntu' errored after 541 milliseconds 95 microseconds: Error running container: template: root:1:7: executing "root" at <.ipv4>: can't evaluate field ipv4 in type *docker.startContainerTemplate

Any ideas?

I know that in general it’s not really necessary to set an IPv4 here - but I’m wondering how, nevertheless.