我是dockerization的新手,并试图为windows应用程序编写docker文件。
我尝试使用Visual Studio代码生成dockerfile。生成的是.Net Core,但我需要.Net Framework。
查看.Net Framework https://hub.docker.com/r/microsoft/dotnet-framework/的官方存储库
docker run -itd --name "MyDotnet" -v "/my/local/path:/home/xdev" microsoft/dotnet-framework
然后,您可以在本地安装目录中部署应用程序
对于.Net Core,请参阅我的Dockerfile for .Net Core作为示例
FROM xzesstence/docker-ubuntu
MAINTAINER "Tim Koepsel"
LABEL dotnet-version="2.1.4"
ENV TZ 'Europe/Brussels'
# https://bugs.debian.org/830696 (apt uses gpgv by default in newer releases, rather than gpg)
RUN set -ex; \
apt-get update; \
if ! which gpg; then \
apt-get install -y --no-install-recommends gnupg; \
fi; \
# Ubuntu includes "gnupg" (not "gnupg2", but still 2.x), but not dirmngr, and gnupg 2.x requires dirmngr
# so, if we're not running gnupg 1.x, explicitly install dirmngr too
if ! gpg --version | grep -q '^gpg (GnuPG) 1\.'; then \
apt-get install -y --no-install-recommends dirmngr; \
fi; \
rm -rf /var/lib/apt/lists/*
RUN apt-key adv --keyserver packages.microsoft.com --recv-keys EB3E94ADBE1229CF && apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893
RUN export DEBIAN_FRONTEND=noninteractive && DEBIAN_FRONTEND=noninteractive apt-get update \
&& echo $TZ > /etc/timezone \
&& apt-get install -y net-tools \
iputils-ping \
curl \
wget \
ca-certificates \
unzip \
tzdata \
&& curl https://packages.microsoft.com/keys/microsoft.asc | /usr/bin/gpg --dearmor > microsoft.gpg \
&& mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
&& sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list' \
&& apt-get update
RUN apt-get install -y dotnet-sdk-2.1.105 \
aspnetcore-store-2.0.6
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
&& dpkg-reconfigure -f noninteractive tzdata \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -d /home/xdev -ms /bin/bash -g root -G sudo xdev
RUN echo 'xdev:123456' | chpasswd
USER xdev
WORKDIR /home/xdev
ENTRYPOINT ["tail", "-f", "/dev/null"]
CMD ["bash"]
您现在可以通过运行来构建dockerfile
docker build --tag dotnet .
然后,您可以运行容器并使用类似的东西挂载本地目录
docker run -itd --name "MyDotnet" -v "/my/local/path:/home/xdev" dotnet
您可以将网络应用程序部署在主机上的/ my / local / path中,或将workdir更改为您要使用的路径
进入容器
docker exec -it MyDotnet bash
在里面,你可以简单地输入
dotnet MyApplication.dll [application arguments]
或者您需要设置正确的入口点,以便您的DLL自动启动
如果适合您,请回答正确答案