Docker 在Linux(Ubuntu 18.04)容器上部署自托管代理时出现的问题

Docker 在Linux(Ubuntu 18.04)容器上部署自托管代理时出现的问题,docker,azure-devops,containers,Docker,Azure Devops,Containers,首先,为了在linux容器上部署自托管代理,我遵循了这一点。我只创建Dockerfile作为start.sh文件(复制和粘贴),以确认我将在此处添加文件: Dockerfile FROM ubuntu:18.04 # To make it easier for build and release pipelines to run apt-get, # configure apt to not require confirmation (assume the -y argument by def

首先,为了在linux容器上部署自托管代理,我遵循了这一点。我只创建Dockerfile作为start.sh文件(复制和粘贴),以确认我将在此处添加文件:

Dockerfile

FROM ubuntu:18.04

# To make it easier for build and release pipelines to run apt-get,
# configure apt to not require confirmation (assume the -y argument by default)
ENV DEBIAN_FRONTEND=noninteractive
RUN echo "APT::Get::Assume-Yes \"true\";" > /etc/apt/apt.conf.d/90assumeyes

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
        ca-certificates \
        curl \
        jq \
        git \
        iputils-ping \
        libcurl4 \
        libicu60 \
        libunwind8 \
        netcat \
        libssl1.0

WORKDIR /azp

COPY ./start.sh .
RUN chmod +x start.sh

CMD ["./start.sh"]
Start.sh

#!/bin/bash
set -e

if [ -z "$AZP_URL" ]; then
  echo 1>&2 "error: missing AZP_URL environment variable"
  exit 1
fi

if [ -z "$AZP_TOKEN_FILE" ]; then
  if [ -z "$AZP_TOKEN" ]; then
    echo 1>&2 "error: missing AZP_TOKEN environment variable"
    exit 1
  fi

  AZP_TOKEN_FILE=/azp/.token
  echo -n $AZP_TOKEN > "$AZP_TOKEN_FILE"
fi

unset AZP_TOKEN

if [ -n "$AZP_WORK" ]; then
  mkdir -p "$AZP_WORK"
fi

rm -rf /azp/agent
mkdir /azp/agent
cd /azp/agent

export AGENT_ALLOW_RUNASROOT="1"

cleanup() {
  if [ -e config.sh ]; then
    print_header "Cleanup. Removing Azure Pipelines agent..."

    ./config.sh remove --unattended \
      --auth PAT \
      --token $(cat "$AZP_TOKEN_FILE")
  fi
}

print_header() {
  lightcyan='\033[1;36m'
  nocolor='\033[0m'
  echo -e "${lightcyan}$1${nocolor}"
}

# Let the agent ignore the token env variables
export VSO_AGENT_IGNORE=AZP_TOKEN,AZP_TOKEN_FILE

print_header "1. Determining matching Azure Pipelines agent..."

AZP_AGENT_RESPONSE=$(curl -LsS \
  -u user:$(cat "$AZP_TOKEN_FILE") \
  -H 'Accept:application/json;api-version=3.0-preview' \
  "$AZP_URL/_apis/distributedtask/packages/agent?platform=linux-x64")

if echo "$AZP_AGENT_RESPONSE" | jq . >/dev/null 2>&1; then
  AZP_AGENTPACKAGE_URL=$(echo "$AZP_AGENT_RESPONSE" \
    | jq -r '.value | map([.version.major,.version.minor,.version.patch,.downloadUrl]) | sort | .[length-1] | .[3]')
fi

if [ -z "$AZP_AGENTPACKAGE_URL" -o "$AZP_AGENTPACKAGE_URL" == "null" ]; then
  echo 1>&2 "error: could not determine a matching Azure Pipelines agent - check that account '$AZP_URL' is correct and the token is valid for that account"
  exit 1
fi

print_header "2. Downloading and installing Azure Pipelines agent..."

curl -LsS $AZP_AGENTPACKAGE_URL | tar -xz & wait $!

source ./env.sh

print_header "3. Configuring Azure Pipelines agent..."

./config.sh --unattended \
  --agent "${AZP_AGENT_NAME:-$(hostname)}" \
  --url "$AZP_URL" \
  --auth PAT \
  --token $(cat "$AZP_TOKEN_FILE") \
  --pool "${AZP_POOL:-Default}" \
  --work "${AZP_WORK:-_work}" \
  --replace \
  --acceptTeeEula & wait $!

print_header "4. Running Azure Pipelines agent..."

trap 'cleanup; exit 130' INT
trap 'cleanup; exit 143' TERM

# To be aware of TERM and INT signals call run.sh
# Running it with the --once flag at the end will shut down the agent after the build is executed
./run.sh & wait $!
尽管从文档中复制和粘贴了这些内容。当它到达start.sh脚本中的第3步(配置Azure Pipelines Agent)时,我收到一个错误

错误消息:qemu-x86_64:无法打开“/lib64/ld-linux-x86-64.so.2”:没有这样的文件或目录

如果有帮助的话,我正在MacOS上运行docker,但正如你所看到的,容器是Ubuntu

谢谢

根据,我们知道Windows和Linux都支持作为容器主机。但MacOS不支持作为容器主机。因此,您可以尝试创建新的Windows docker容器以重试。

谢谢,也许我忽略了这一点,或者我认为这是在说,与托管容器的操作系统相比,只支持Windows和linux容器。将此标记为正确答案,并使用Linux虚拟机继续前进。谢谢。你能接受它作为一个答案,这样它可以帮助其他社区成员谁得到同样的问题,我们可以存档这个线程,谢谢。这个问题怎么样?下面的答案是否解决了您的问题,如果是,您可以接受它作为一个答案,这样它可以帮助其他社区成员谁得到相同的问题,我们可以存档此线程,谢谢。如果没有,请告诉我们您是否需要进一步的帮助。