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!