简体   繁体   English

使用Docker-compose构建Dotnet应用程序

[英]Dotnet application build using Docker-compose

I am looking for some help in build a robust docker-compose file. 我在构建健壮的docker-compose文件时寻求帮助。 I have my docker images in my private repository, Before i used to pull all images and then used to try docker run commands individually to build a container. 我将docker映像保存在私有存储库中,在此之前,我先提取所有映像,然后再尝试分别运行docker run命令来构建容器。 Now i am planning to build a docker-compose file. 现在我正计划构建一个docker-compose文件。

Manual commands used: 使用的手动命令:

docker run --restart unless-stopped -t -d --name test_rest -p 9095:80 --entrypoint dotnet test_rest script_var.Core.dll test_var:MongoSource=mongodb://192.168.22.22 KafkaReceiveStream:KafkaBroker=192.168.22.22:9092 KafkaReceiveStream:KafkaTopic=testevents KafkaSendStream:KafkaTopic=test_key KafkaSendStream:KafkaBroker=192.168.22.22:9092

docker run --restart unless-stopped -t -d --name test_app1 -p 9096:80 --entrypoint dotnet test_app1 script_var.Core.dll test_var:MongoSource=mongodb://192.168.22.22

docker run --restart unless-stopped -t -d --name test_app2 --entrypoint dotnet test_app2 script_var.Core.dll

Now I would like to build a docker-compose file out from above commands. 现在,我想从上述命令中构建一个docker-compose文件。

version: '2.1'
networks:
  mynetwork:
    driver: bridge
services:
  test_reste:
    image: test_rest
    ports:
      - "9095:80"
    networks:
      - mynetwork
  test_app1:
    image: test_app1
    ports:
      - "9096:80"
    networks:
      - mynetwork
  test_app2:
    image: test_app2
    networks:
      - mynetwork

How can we add the entry point in docker-compose file, i tried to add 我们如何在docker-compose文件中添加入口点,我尝试添加

image: test_rest
   entrypoint:
     - dotnet
     - test_rest
     - script_var.Core.dll
     .
     .
     .

This is the error i got: 这是我得到的错误:

Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
test_rest_1  |   http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Can some one help me how can we solve this issue? 可以帮我解决这个问题吗?

Thanks in advance. 提前致谢。

Not sure if you ended up figuring this out but the place to put your ENTRYPOINT is in the Dockerfile , not the docker-compose file. 不知道您是否最终弄清楚了这个问题,但将ENTRYPOINT放置在Dockerfile ,而不是Dockerfile docker-compose文件中。

So your Dockerfile might look something like this: 因此,您的Dockerfile可能看起来像这样:

FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
WORKDIR /app
EXPOSE 9095
EXPOSE 9096

FROM pathToYourImage AS build
WORKDIR /src

# ... you should already have a Dockerfile for your private repos images? ...

ENTRYPOINT ["dotnet", "test_rest.dll"]

EDIT 1: My apologies, you can add entrypoint to your compose. 编辑1:对不起,您可以将入口点添加到您的撰写。 For example: 例如:

entrypoint: ["dotnet", "test_rest.dll"]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Dotnet watch 在 docker-compose 中失败 - Dotnet watch failing in docker-compose 在不需要的地方运行 dotnet 的 Rider 中的 Docker-compose - Docker-compose in Rider running dotnet where it is not needed 为什么我的 .NET Web API 应用程序在使用 docker-compose 时无法连接到 docker 上的 MySQL? - Why does my .NET web API application not connect to MySQL on docker when using docker-compose? Azure 函数 v3 将调试器附加到本地 docker 容器,以 docker-compose (dotnet) 开始 - Azure functions v3 attach debugger to docker container in local started with docker-compose (dotnet) 是否可以在 Docker-compose 中为构建上下文指定绝对路径? - Is it possible to specify absolute path in Docker-compose for build context? 在 docker 内构建 do.net 核心应用程序 - 永远运行 - Build dotnet core application within docker - runs forever 运行 docker-compose build 后恢复软件包时收到“无法建立 SSL 连接”消息 - Receiving 'The SSL connection could not be established' message when restoring packages after running docker-compose build 带有版本的 dotnet 构建在 docker 中不起作用 - dotnet build with version is not working in docker 无法在 docker 中构建 dotnet 项目 - Unable to build dotnet project in docker Docker-compose 未能读取 Dockerfile - Docker-compose failed to read Dockerfile
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM