带Linux Docker容器的Asp.net核心

编程入门 行业动态 更新时间:2024-10-24 08:31:21
本文介绍了带Linux Docker容器的Asp核心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

对于VS 2017中的asp核心项目模板,有do​​cker-compose.ci.build.yml:

For a asp core project template in VS 2017, there are docker-compose.ci.build.yml:

version: '3' services: ci-build: image: microsoft/aspnetcore-build:1.0-2.0 volumes: - .:/src working_dir: /src command: /bin/bash -c "dotnet restore ./WebAppCoreDockerTest.sln && dotnet publish ./WebAppCoreDockerTest.sln -c Release -o ./obj/Docker/publish"

docker-compose.yml:

docker-compose.yml:

version: '3' services: webappcoredockertest: image: webappcoredockertest ports: - 8080:80 build: context: ./WebAppCoreDockerTest dockerfile: Dockerfile

和Dockerfile:

and Dockerfile:

FROM microsoft/aspnetcore:2.0 ARG source WORKDIR /app EXPOSE 80 RUN echo "Oh dang look at that $source" COPY ${source:-obj/Docker/publish} . ENTRYPOINT ["dotnet", "WebAppCoreDockerTest.dll"]

Dockerfile使用文件在obj / Docker / publish(复制到容器)中,如果源参数为null,并且docker-compose.ci.build.yml将项目推向obj / Docker / publish,我认为它们是相关的。

The Dockerfile uses the files in obj/Docker/publish (copied to container) if source argument is null and docker-compose.ci.build.yml puhlishs project to obj/Docker/publish, I assume they are related.

所以问题是如何一起使用? (docker-compose.ci.build.yml将文件发布到obj / Docker / publish,并且Dockerfile使用已发布的文件)

So the question is How to use them together? (docker-compose.ci.build.yml publishes files to obj/Docker/publish and Dockerfile use published files)

推荐答案

The如您所述, docker-compose.ci.build.yml 文件用于构建项目。它使用 aspnetcore-build 基本映像,该映像比Dockerfile使用的 aspnetcore 映像要重得多。 Dockerfile 被docker-compose.yml文件的 build 部分使用。

The docker-compose.ci.build.yml file is for building the project, as you mentioned. It uses the aspnetcore-build base image which is much heftier than the aspnetcore image used by the Dockerfile. The Dockerfile gets used by the build section of the docker-compose.yml file.

一切都可以通过以下两个步骤来完成:

Everything works together with these two steps:

  • docker-compose -f docker -compose.ci.build.yml运行ci-build
  • docker-compose up --build
  • docker-compose -f docker-compose.ci.build.yml run ci-build
  • docker-compose up --build
  • 第一个命令中的 -f 选项可让您指定撰写默认文件 docker-compose.yml 以外的文件。

    The -f option in the first command allows you to specify a compose file other than the default docker-compose.yml.

    更多推荐

    带Linux Docker容器的Asp.net核心

    本文发布于:2023-11-17 04:38:14,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1608851.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:容器   核心   Docker   Linux   Asp

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!