简体   繁体   English

仅在docker容器中使用cmd打开和编辑文件

[英]Open and edit file using cmd only in docker container

I'm building a docker image for windows.我正在为 Windows 构建一个 docker 镜像。 The dockerfile used for this image is split to build stange and runtime.用于此映像的 dockerfile 被拆分以构建 stange 和运行时。 For the runtime I'm using mcr.microsoft.com/dotnet/core/aspnet:2.2 which is striped to the bone.对于运行时,我使用的是 mcr.microsoft.com/dotnet/core/aspnet:2.2,它是条带化的。 Inside the container I have a file, appsettings.json which I would like to open to view and also edit, but have no idea how.在容器内,我有一个文件 appsettings.json,我想打开它进行查看和编辑,但不知道如何打开。

Also is there anyway that I can use the CMD to install anything ?无论如何我可以使用CMD安装任何东西吗? and if not what other choices do i have ?如果没有,我还有什么其他选择?

Instead of modifying config inside of container you can map directory from host into container ( -v C:\\config:C:\\config ) - so you can edit config directly on host.您可以将目录从主机映射到容器( -v C:\\config:C:\\config ),而不是修改容器内的-v C:\\config:C:\\config - 这样您就可以直接在主机上编辑配置。

You can install applications in container, but each application usually require own set of options for that.您可以在容器中安装应用程序,但每个应用程序通常需要自己的一组选项。 Often it is easier to use chocolatey for that:通常使用巧克力更容易:

RUN powershell -NoProfile -InputFormat None -ExecutionPolicy Bypass -Command "iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))"
RUN choco feature enable -n=allowGlobalConfirmation
RUN choco feature disable -n=showDownloadProgress
RUN choco install <your-app>

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM