我希望能够从docker机器外部和内部对Identity Server(STS)进行身份验证.
我在设置容器内外的正确权限时遇到问题.如果我将权限设置为内部名称,mcoidentityserver:5000则API可以进行身份验证,但客户端无法获取令牌,因为客户端位于docker网络之外.如果我将权限设置为外部名称,localhost:5000则客户端可以获取令牌,但API无法识别权限名称(因为localhost在这种情况下是主机).
我该如何设置权限?或许我需要调整码头网络?
我正在设置一个Windows 10 docker开发环境,它使用ASP.NET Core API(在Linux上),Identity Server 4(Linux上的ASP.NET Core)和PostgreSQL数据库.PostgreSQL不是问题,包含在图表中以保证完整性.它被映射到9876,因为我现在还在主机上运行了一个PostgreSQL实例.mco是我们公司的简称.
我一直在遵循Identity Server 4的说明来启动和运行.
我不包括docker-compose.debug.yml它,因为它运行的命令只与在Visual Studio中运行相关.
泊坞窗,compose.yml
version: '2'
services:
mcodatabase:
image: mcodatabase
build:
context: ./Data
dockerfile: Dockerfile
restart: always
ports:
- 9876:5432
environment:
POSTGRES_USER: mcodevuser
POSTGRES_PASSWORD: password
POSTGRES_DB: mcodev
volumes:
- postgresdata:/var/lib/postgresql/data
networks:
- mconetwork
mcoidentityserver:
image: mcoidentityserver
build:
context: ./Mco.IdentityServer
dockerfile: Dockerfile
ports:
- 5000:5000
networks:
- mconetwork
mcoapi: …Run Code Online (Sandbox Code Playgroud) 当我运行以下命令时,我希望退出代码为 0,因为我的combined容器运行了一个成功退出的测试,退出代码为 0。
docker-compose up --build --exit-code-from combined
Run Code Online (Sandbox Code Playgroud)
不幸的是,即使我的combined容器中的测试成功运行,我也始终收到 137 的退出代码,并且我以 0 的退出代码退出该容器(下面指定了有关如何发生的更多详细信息)。
以下是我的 docker-compose 版本:
docker-compose version 1.25.0, build 0a186604
Run Code Online (Sandbox Code Playgroud)
根据这篇文章,137 的退出代码可能是由于两个主要问题。
docker stop,应用程序没有正常处理 SIGTERM我知道 137 退出代码不是因为我的容器内存不足。当我运行时docker inspect <container-id>,我可以看到“OOMKilled”是假的,如下面的代码片段所示。我还为 Docker 引擎分配了 6GB 的内存,这对于我的应用程序来说已经足够了。
[
{
"Id": "db4a48c8e4bab69edff479b59d7697362762a8083db2b2088c58945fcb005625",
"Created": "2019-12-12T01:43:16.9813461Z",
"Path": "/scripts/init.sh",
"Args": [],
"State": {
"Status": "exited",
"Running": false,
"Paused": false,
"Restarting": false,
"OOMKilled": false, <---- shows container did not run out of memory
"Dead": …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 docker 容器内以开发模式运行角度应用程序,但是当我使用 docker-compose build 运行它时,它可以正常工作,但是当我尝试放置容器时,我收到以下错误:
ERROR: for sypgod Cannot start service sypgod: OCI runtime create failed: container_linux.go:346: starting container process caused "exec: \"npm\": executable file not found in $PATH
Run Code Online (Sandbox Code Playgroud)
真正的问题是它无法识别命令 npmserve,但为什么?
设置如下:
Docker 容器(Nginx 反向代理 -> Angular 在端口 4000 中运行)
我知道有更好的部署方法,但目前出于某些个人原因我需要此设置
Dockerfile:
FROM node:10.9
COPY package.json package-lock.json ./
RUN npm ci && mkdir /angular && mv ./node_modules ./angular
WORKDIR /angular
RUN npm install -g @angular/cli
COPY . .
FROM nginx:alpine
COPY toborFront.conf /etc/nginx/conf.d/
EXPOSE 8080
CMD ["nginx", "-g", "daemon …Run Code Online (Sandbox Code Playgroud) 我已经将 Windows 10 更新到 2004 最新版本,安装了 wsl2 并更新了它,安装了 docker 和 ubuntu。
当我使用“Hello World”创建一个简单的index.php文件时,它运行良好(响应:100-400ms)但是当我添加我的Laravel项目时,它变得很糟糕,因为它在执行请求之前加载了 7秒,响应为4 - 7秒,即使PHPMyAdmin运行非常顺利(响应:1 - 2 秒)。
我的 docker-compose.yml文件:
version: '3.8'
networks:
laravel:
services:
nginx:
image: nginx:stable-alpine
container_name: nginx
ports:
- "8080:80"
volumes:
- ./src:/var/www/html
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
depends_on:
- php
- mysql
- phpmyadmin
networks:
- laravel
mysql:
image: mysql:latest
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: secret
SERVICE_TAGS: dev
SERVICE_NAME: mysql …Run Code Online (Sandbox Code Playgroud) docker docker-compose windows-subsystem-for-linux docker-for-windows
我是 Docker 的新手,并尝试使用纯 html 构建 docker 映像,但我收到此错误消息,说 无法使用前端 dockerfile.v0 解决:无法读取 dockerfile:open /var/lib/docker/tmp/buildkit-mount602954594 /Dockerfile: 没有那个文件或目录
我的文件夹目录是这样的
C:\Users\hailey\Desktop\GitTest
|- Dockerfile.txt
|- README.md
|- testHelloWorld.html
Run Code Online (Sandbox Code Playgroud)
在 Dockerfile 里面,我有
FROM ubuntu
WORKDIR C/Users/hailey/Desktop/GitTest
COPY testHelloWorld.html .
EXPOSE 8080
CMD ["html","testHelloWorld.html"]
Run Code Online (Sandbox Code Playgroud)
我做了我的命令 docker build 。在目录 C:\Users\hailey\Desktop\GitTest 内。然后得到
[+] Building 0.1s (2/2) FINISHED
=> [internal] load build definition from Dockerfile
=> => transferring dockerfile: 2B
=> [internal] load .dockerignore
=> => transferring context: 2B
failed to solve with frontend dockerfile.v0: failed to read dockerfile: …Run Code Online (Sandbox Code Playgroud) 我已经寻找答案有一段时间了,但我还没有找到它,在继续测试之前我需要理解它。
我正在通过安装 bash 创建基于 Alpine 的映像,如下图所示:
FROM alpine:3.12
RUN apk add --no-cache --upgrade bash rsync gzip \
&& rm -rf /var/cache/apk/*
COPY ./docker/backup/hello.sh /hello.sh
RUN mkdir /backup \
&& chmod u+x /hello.sh
WORKDIR /backup
ENTRYPOINT ["sh","/hello.sh"]
CMD ["/bin/bash"]
Run Code Online (Sandbox Code Playgroud)
你好.sh
#!/bin/sh
echo "=> Hello Word"
echo "$@"
exec "$@"
Run Code Online (Sandbox Code Playgroud)
我第一次尝试 bash 时无法使用以下命令访问:
docker-compose exec myalpine bash
Run Code Online (Sandbox Code Playgroud)
但是搜索是否找到答案,我必须放入 docker-compose.yml ,并且在启动命令后tty: true我已经能够访问容器 shellmyalpinedocker-compose up -d
导致我的 docker-compose.yml 的一部分如下
services:
myalpine:
build:
context: ./
dockerfile: ./docker/backup/Dockerfile
args:
- DOCKER_ENV=${DOCKER_ENV}
restart: …Run Code Online (Sandbox Code Playgroud) 当构建需要从打字稿编译的图像时,我收到此错误。
sh: 1: tsc: 未找到
命令“/bin/sh -c npm run tsc”返回非零代码:127
这是相关代码:
docker-compose.yaml
version: '3.1'
services:
nodeserver:
build:
context: .
target: prod
ports:
- "3000:3000"
volumes:
- ./src:/app/src
- ./public:/app/public
- ./templates:/app/templates
Run Code Online (Sandbox Code Playgroud)
Dockerfile
FROM node:15.11.0 AS base
EXPOSE 3000
ENV NODE_ENV=production
WORKDIR /app
COPY package*.json ./
RUN npm install --only=production && npm cache clean --force
##########################################################################################
FROM base AS dev
ENV NODE_ENV=development
RUN npm install --only=development
CMD npm run dev
##########################################################################################
FROM dev AS source
COPY dist dist
COPY templates templates …Run Code Online (Sandbox Code Playgroud) 我有这个多容器项目,由 3 个 NestJS 和 1 个 dotnet5.0 应用程序组成。除了应用程序之外,该项目还依赖于 RabbitMQ 和 InfluxDB 服务(作为纯 docker 镜像运行)
该docker-compose文件如下所示:
version: '3.8'
services:
influxdb:
image: influxdb:2.0
container_name: influxdb
ports:
- '8086:8086'
expose:
- '8086'
volumes:
- ./data/influxdb2/data:/var/lib/influxdb2
- ./data/influxdb2/config:/etc/influxdb2
rabbitmq:
hostname: 'rabbitmq'
image: rabbitmq:3-management
container_name: rabbitmq
ports:
- '15672:15672'
- '5672:5672'
microservice1:
image: microservice1
container_name: microservice1
depends_on: [rabbitmq, influxdb]
build:
context: .
dockerfile: ./apps/microservice1/Dockerfile
microservice2:
image: microservice2
container_name: microservice2
depends_on: [rabbitmq, influxdb]
build:
context: .
dockerfile: ./apps/microservice2/Dockerfile
microservice3:
image: microservice3
container_name: microservice3 …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 dockerfile 将我的 django 应用程序部署到应用程序引擎,为此,在阅读了一些博客(例如这些)之后,我创建了一个 docker-compose.yml 文件,但是当我运行命令时docker compose up,docker-compose -f docker-compose-deploy.yml run --rm gcloud sh -c "gcloud app deploy"我收到了错误key cannot contain a space。见下文:
例如:
$ docker compose up
key cannot contain a space
Run Code Online (Sandbox Code Playgroud)
$ cat docker-compose.yml
version: '3.7'
services:
app:
build:
context: .
ports: ['8000:8000']
volumes: ['./app:/app']
Run Code Online (Sandbox Code Playgroud)
有人可以帮我解决这个错误吗?我已尝试 yamllint 验证 yaml 文件是否存在任何空格/缩进类型的错误,并且它没有向我显示任何错误。
编辑:这是较长命令中文件的内容:
version: '3.7'
services:
gcloud:
image: google/cloud-sdk:338.0.0
volumes:
- gcp-creds:/creds
- .:/app
working_dir: /app
environment:
- CLOUDSDK_CONFIG=/creds
volumes:
gcp-creds:
Run Code Online (Sandbox Code Playgroud) 我有一个安装程序,可以将一些值输出到 .env 文件中,供 docker-compose 使用。到目前为止,所有这些都有效,但似乎无法使用的 SSH 密钥除外。
到目前为止,我已经尝试使用正确格式的私钥并用\n. 但是,这会进一步中断工作流程,并且不会在容器内使用 printenv 作为所需的多行变量出现。
docker-compose.yml
myservice:
build: .
environment:
- SSH_KEY
- SINGLE_LINE_VALUE
Run Code Online (Sandbox Code Playgroud)
.env(忽略明显损坏的 sshkey)
SINGLE_LINE_VALUE=I Load just fine
SSH_KEY="---------------
ABCDEFGH
--------------------
"
Run Code Online (Sandbox Code Playgroud)
到容器运行时,SSH_KEY 的环境值只是“---------------
非常感谢任何想法。
docker ×10
docker-compose ×10
dockerfile ×3
node.js ×2
angular ×1
cypress ×1
npm ×1
typescript ×1
windows-subsystem-for-linux ×1
yaml ×1