首页 > 其他分享 >dcoker 腾讯云个人版镜像仓库

dcoker 腾讯云个人版镜像仓库

时间:2023-01-09 18:24:12浏览次数:51  
标签:个人版 dockertest dcoker build dotnet 镜像 docker com DockerTest

1.新建webapi接口net7项目

2.设置docker支持

3.本地要安装docker 

window 安装docker desktop   https://docs.docker.com/desktop/

4.右键终端打开项目

5.查看docker 版本

6.配置dockerfile

dotnet restore 命令使用 NuGet 还原依赖项以及在 project 文件中指定的特定于项目的工具

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 5005

ENV ASPNETCORE_ENVIRONMENT=Development
ENV ASPNETCORE_URLS http://+:5005

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /src
COPY ["Dev.DockerTest.csproj", "./"]
RUN dotnet restore "./Dev.DockerTest.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "Dev.DockerTest.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Dev.DockerTest.csproj" -c Release -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Dev.DockerTest.dll"]

 docker build -t dockertest .

7.腾讯云创建个人镜像服务

根据提示操作

终端切换登录

 docker login --username=xxx ccr.ccs.tencentyun.com

打包镜像

 docker tag eeaf3e107fdf ccr.ccs.tencentyun.com/mytxspace/dockertest:v1

push 

docker push ccr.ccs.tencentyun.com/mytxspace/dockertest:v1

7.docker 拉取镜像

docker pull ccr.ccs.tencentyun.com/mytxspace/dockertest:v1

8.docker run 镜像

docker run -itd --name dockertest -p 5004:5005 ccr.ccs.tencentyun.com/mytxspace/dockertest:v1

 

标签:个人版,dockertest,dcoker,build,dotnet,镜像,docker,com,DockerTest
From: https://www.cnblogs.com/elsons/p/17037872.html

相关文章