0

I am trying to test the docker file in local through docker desktop but it not completing successfully but same dockerFile is working through ado pipeline and I am able to build and publish the image to repo. but Not able to test in locally by building it . can some one help me. here is docker file content

# Use a base Ubuntu image
FROM ubuntu:22.04

# Set environment variables
ENV TARGETARCH="linux-x64"

# Update apt cache and install required packages
RUN apt-get update && \
    apt-get install -y \
        git \
        build-essential \
        unzip \
        lxc \
        wget \
        gpg \
        iptables \
        sudo \
        jq \
        libicu70 \
        bc \
        bash \
        iputils-ping \
        gnupg \
        lsb-release \
        telnet \
        ssh \
        nodejs \
        npm \
        gcc \
        sshpass \
        curl && \
    rm -rf /var/lib/apt/lists/*

# Install Azure CLI
RUN curl -sL https://aka.ms/InstallAzureCLIDeb | bash

ARG TERRAFORM_VERSION=1.3.1

RUN wget -q "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -O tf.zip && \
    unzip tf.zip && \
    mv ./terraform /usr/local/bin/terraform && \
    chmod +x /usr/local/bin/terraform && \
    rm tf.zip

# Expose SSH and any other ports as necessary
EXPOSE 22

# Set working directory
WORKDIR /azp/

# Copy start script
COPY ./start.sh ./ 
RUN chmod +x ./start.sh

# Create agent user and set up home directory
RUN useradd -m -d /home/agent agent
RUN chown -R agent:agent /azp /home/agent

USER agent
# Another option is to run the agent as root.

ENTRYPOINT [ "./start.sh" ]

and getting error in terminal is as follow

 => ERROR [4/9] RUN wget -q "https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_linux_amd64.zip" -O tf.zip &&     unzip tf.zip &&     mv ./terraform /usr/local/bin/terraform &&     chmod +x /usr/local/bin  0.5s
------
 > [4/9] RUN wget -q "https://releases.hashicorp.com/terraform/1.3.1/terraform_1.3.1_linux_amd64.zip" -O tf.zip &&     unzip tf.zip &&     mv ./terraform /usr/local/bin/terraform &&     chmod +x /usr/local/bin/terraform &&     rm tf.zip:
------
Dockerfile:47
--------------------
  46 |
  47 | >>> RUN wget -q "https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip" -O tf.zip && \
  48 | >>>     unzip tf.zip && \
  49 | >>>     mv ./terraform /usr/local/bin/terraform && \
  50 | >>>     chmod +x /usr/local/bin/terraform && \
  51 | >>>     rm tf.zip
  52 |
--------------------
ERROR: failed to solve: process "/bin/sh -c wget -q \"https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip\" -O tf.zip &&     unzip tf.zip &&     mv ./terraform /usr/local/bin/terraform &&     chmod +x /usr/local/bin/terraform &&     rm tf.zip" did not complete successfully: exit code: 5
2
  • Which step in that RUN command is failing? If it's the wget, have you double-checked that the URL is correct? Is there any more to the error than what you show? Terraform might not run well in a container, since it needs both local state and credentials that might not be readily accessible in an isolated environment; can you run it directly on the host system? Commented Mar 27 at 5:49
  • Yes RUN failed for wget and URL is correct, and in host system its working fine . but when i test through local docker desktop getting this exception Commented Mar 27 at 17:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.