【发布时间】:2018-11-10 21:28:43
【问题描述】:
在 vsts 代理盒上安装了 docker 18.03(自托管 VSTS 代理) 运行代理的用户已添加到 docker 组。 当我尝试在 VSTS 中使用 Docker Compose 任务构建时,构建失败并出现错误:
无法通过 http+docker://localhost 连接到 Docker 守护程序 - 它正在运行吗? 如果它位于非标准位置,请使用 DOCKER_HOST 环境变量指定 URL。 无法在 http+docker://localhost 连接到 Docker 守护程序 - 它正在运行吗? 如果它位于非标准位置,请使用 DOCKER_HOST 环境变量指定 URL。 /usr/local/bin/docker-compose 失败,返回码:1
我已经被困了几个小时,任何帮助都会很棒。
另一个注意事项:docker compose 在代理框中工作得非常好,但是当构建由 VSTS 任务触发时,我收到此错误。
docker-compose 文件:
version: '3'
services:
some-api:
build:
context: .
dockerfile: .docker/dockerfile1
image: some.azurecr.io/some-api:latest
container_name: 'some-api'
ports:
- '8080:80'
some-website:
build:
context: .
dockerfile: .docker/dockerfile2
image: some.azurecr.io/some-website:latest
container_name: 'some-website'
ports:
- '3434:3434'
dockerfile -api
FROM microsoft/dotnet AS build
# Docker image container .NET Core SDK
COPY .api/ ./some-api
WORKDIR /some-api
RUN dotnet restore; dotnet publish -o out
# final image
FROM microsoft/aspnetcore
# .NET Core runtime-only image
COPY --from=build /some-api/out /some-api
WORKDIR /some-api
EXPOSE 80
ENTRYPOINT [ "dotnet", "some.dll" ]
dockerfile-网站
#----------------------
### STAGE 1: BUILD ###
#---------------------
# Building node from LTS version
FROM node:8.11.1 as builder
# Installing npm to remove warnings and optimize the container build process
# One of many warnings: npm WARN notice [SECURITY] deep-extend has 1 low vulnerability.
#Go here for more details: https://nodesecurity.io/advisories?search=deep-extend&version=0.5.0 -
#Run `npm i npm@latest -g` to upgrade your npm version, and then `npm audit` to get more info.
RUN npm install npm@latest -g
# Copying all necessary files required for npm install
COPY package.json ./
# Install npm dependencies in a different folder to optimize container build process
RUN npm install
# Create application directory and copy node modules to it
RUN mkdir /some-website
RUN cp -R ./node_modules ./some-website
# Setting application directory as work directory
WORKDIR /some-website
# Copying application code to container application directory
COPY . .
# Building the angular app
RUN npm run build.prod
#--------------------------------------------------
### STAGE 2: Setup nginx and Deploy application ###
#--------------------------------------------------
FROM nginx:latest
## Copy defualt ngninx configuration file
COPY default.conf /etc/nginx/conf.d
## Remove default nginx website
RUN rm -rf /usr/share/nginx/hmtl/*
# Copy dist folder from the builder to nginx public folder(STAGE 1)
COPY --from=builder /some-website/dist/prod /usr/share/nginx/html
CMD ["nginx","-g","daemon off;"]
谢谢
【问题讨论】:
-
我已经尝试了这里的所有建议:docs.docker.com/install/linux/linux-postinstall/#systemd
-
您能否确认您在正确的代理上运行构建?您不会不小心在托管代理(或完全不同的代理)上运行它吗?
-
@DanielMann 是的,我确认我在正确的代理上运行构建。
-
自托管 VSTS 代理是指托管代理吗?您的构建定义的任务是什么? docker compose file和dockerfile的详细代码是什么?
-
@starianchen-MSFT 在问题中添加了 docker-compose 和 dockerfile,我只有一个 Docker Compose 任务。自托管代理是指本地安装的代理,而不是 VSTS 托管代理。感谢您的帮助。
标签: docker docker-compose azure-devops azure-pipelines azure-pipelines-build-task