VSTS中的Docker Compose任务:无法连接到http + docker:// localhost的Docker守护程序 - 它是否正在运行?

时间:2018-05-31 19:33:02

标签: docker docker-compose azure-devops azure-pipelines azure-pipelines-build-task

在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失败,返回码为:

我被困在这里几个小时,任何帮助都会很棒。

还有一点需要注意:docker compose在代理框中运行得非常好,但是当VSTS任务触发构建时,我会收到此错误。

docker-compose file:

 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;"]

由于

1 个答案:

答案 0 :(得分:1)

The issue was user permissions. So after adding a user to the docker group,

sudo usermod -aG docker $USER

logging out and logging in didn't work. I had to reboot my ubuntu server in order for permissions to take effect.