Docker 在 VSTS 中编写任务:无法连接到位于 http+docker://localhost 的 Docker 守护程序 - 是 运行 吗?
Docker Compose task in VSTS : Couldn't connect to Docker daemon at http+docker://localhost - is it running?
已在 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 失败,return 代码:1
我已经被困在这个问题上几个小时了,任何帮助都会很棒。
请注意:docker compose 在代理框中工作得很好,但是当构建由 VSTS 任务触发时,我收到此错误。
docker-编写文件:
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'
docker文件-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" ]
docker文件网站
#----------------------
### 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;"]
谢谢
问题出在用户权限上。所以在将用户添加到 docker 组后,
sudo usermod -aG docker $USER
注销和登录无效。我必须重新启动我的 ubuntu 服务器才能使权限生效。
已在 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 失败,return 代码:1
我已经被困在这个问题上几个小时了,任何帮助都会很棒。
请注意:docker compose 在代理框中工作得很好,但是当构建由 VSTS 任务触发时,我收到此错误。
docker-编写文件:
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'
docker文件-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" ]
docker文件网站
#----------------------
### 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;"]
谢谢
问题出在用户权限上。所以在将用户添加到 docker 组后,
sudo usermod -aG docker $USER
注销和登录无效。我必须重新启动我的 ubuntu 服务器才能使权限生效。