[SOLVED] Docker provider: start a container with systemd enabled

I’m trying to start a Fedora 31 container which needs systemd to be enabled.
As an example, this works on the CLI to get things going:

docker run -d --privileged -v /sys/fs/cgroup:/sys/fs/cgroup:ro --name fc31 fedora:31 /usr/lib/systemd/systemd --system

File main.tf:

# Configure Docker provider and connect to the local Docker socket
provider "docker" {
  host = "unix:///var/run/docker.sock"
}

# Pull fedora:31
resource "docker_image" "fedora" {
  name = "fedora:31"
}

# Create a Fedora 31 container
resource "docker_container" "fedora" {
    depends_on = [
    docker_image.fedora,
  ]

  image = "fedora:31"
  name  = "fc31"

  privileged = true
  start = true
  must_run = true

  ports {
    internal = 80
    external = 80
  }

  upload {
    source = "${path.module}/deploy.sh"
    file   = "/deploy.sh"
  }

  command = ["/bin/bash", "-x", "/deploy.sh" ]

}

In the deploy.sh script being called are some systemctl-commands which fail:

2020-02-20T16:30:01.056848782Z + sudo systemctl daemon-reload
2020-02-20T16:30:01.069708041Z System has not been booted with systemd as init system (PID 1). Can't operate.
2020-02-20T16:30:01.069734469Z Failed to connect to bus: Host is down

Is it possible to start the container with systemd from the Terraform provider and if yes what should be added to main.tf?
TIA!

Answering my own question.

“Vanilla” Fedora 31 will not work. A F31 based image with systemd installed will.
Here I use the Docker image created in the official Cobbler CI-build.
Ref: https://github.com/cobbler/cobbler/blob/master/.travis.yml#L36

# Configure Docker provider and connect to the local Docker socket
provider "docker" {
  host = "unix:///var/run/docker.sock"
}

# Use cobbler:f31 (based on Fedora 31)
resource "docker_image" "cobbler" {
  name = "cobbler:f31"
}

# Custom Fedora 31 container to run Cobbler 3.x in
resource "docker_container" "cobbler" {
  image = "cobbler:f31"
  name  = "cobbler-f31"

  privileged = true
  must_run   = true

  volumes {
    container_path = "/sys/fs/cgroup"
    host_path      = "/sys/fs/cgroup"
    read_only      = true
  }

  ports {
    internal = 80
    external = 80
  }

  upload {
    source     = "${path.module}/deploy.sh"
    file       = "/deploy.sh"
    executable = true
  }

  entrypoint = ["/usr/lib/systemd/systemd", "--system"]
  #command    = ["/bin/bash", "-x", "/deploy.sh"]

}

ATM you’ll have to enter the container to run deploy.sh manually, the command won’t (yet).