Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "/usr/local/bin/terraform": stat /usr/local/bin/terraform: no such file or

Hello everyone,

I am currently in the process of creating an image for the GitHub action for Terraform, but I have encountered an error after the build. The error message is as follows:

Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: “/usr/local/bin/terraform”: stat /usr/local/bin/terraform: no such file or directory: unknown.

Here is the Dockerfile I am using:

FROM golang:1.12.6 AS tfmask

RUN git clone https://github.com/cloudposse/tfmask.git \
 && cd tfmask \
 && git checkout 9a15f421210397f2c321a57b5ed3d108a012a86d \
 && make \
 && make go/build

FROM debian:bullseye-slim as base

# Terraform environment variables
ENV CHECKPOINT_DISABLE=true
ENV TF_IN_AUTOMATION=true
ENV TF_INPUT=false
ENV TF_PLUGIN_CACHE_DIR=/usr/local/share/terraform/plugin-cache

RUN apt-get update  \
 && apt-get install --no-install-recommends -y \
    git \
    ssh \
    tar \
    gzip \
    ca-certificates \
    curl \
    unzip \
    jq \
    python3 \
    python3-requests \
    python3-pip \
    wget \
    gpg \
    gpg-agent \
    dirmngr \
    tree \
 && rm -rf /var/lib/apt/lists/*

RUN mkdir -p $TF_PLUGIN_CACHE_DIR

COPY --from=tfmask /go/tfmask/release/tfmask /usr/local/bin/tfmask
ENV TFMASK_RESOURCES_REGEX="(?i)^(random_id|kubernetes_secret|acme_certificate).*$"

ENTRYPOINT ["/usr/local/bin/terraform"]

To troubleshoot, I attempted to change the ENTRYPOINT to “bash,” which allowed me to access the container. However, I was unable to find the Terraform binary at “/usr/local/bin/terraform.”

Additionally, during the image building process, I encountered the following warnings:

sockets not supported  
ERRO[0000] Can't add file /root/.gnupg/S.gpg-agent.browser to tar: archive/tar: sockets not supported 
ERRO[0000] Can't add file /root/.gnupg/S.gpg-agent.extra to tar: archive/tar: sockets not supported 
ERRO[0000] Can't add file /root/.gnupg/S.gpg-agent.ssh to tar: archive/tar: sockets not supported 

I would greatly appreciate any insights or guidance from those with experience in this area.

Thank you very much for your time and assistance.

I don’t see how you install the terraform client. You are using a debian base image. So how should the terraform client be in the image?

Hi rimelek, sorry for late reply as i was busy with some other tasks. you were right I was missing it. then I updated my docker file with following code.

&& curl -O https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
&& unzip terraform_${TERRAFORM_VERSION}linux_amd64.zip
&& mv terraform /usr/local/bin/terraform
&& chmod +x /usr/local/bin/terraform
&& rm terraform
${TERRAFORM_VERSION}_linux_amd64.zip

after adding the instalation of terraform, i was able to set the entry point.