NETCORE 之 openSUSE docker 安装

2019/03/25 14:25
阅读数 48

openSUSE docker 安装
https://www.jianshu.com/p/c725a06447d5


http://www.importnew.com/24684.html
Suse安装Docker
https://blog.csdn.net/llqkk/article/details/50488870

1. 添加仓库

##zypper addrepo -f cd:///?devices=/dev/disk/by-id/ata-QEMU_DVD-ROM_QM00003 SLES12-SP2-12
zypper addrepo -f https://mirrors.aliyun.com/opensuse/update/leap/42.3/oss openSUSE-42.3-Update-Oss
zypper addrepo -f https://mirrors.aliyun.com/opensuse/update/leap/42.3/non-oss/ openSUSE-42.3-Update-Non-Oss
zypper addrepo -f https://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/oss/ openSUSE-42.3-Oss
zypper addrepo -f https://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/non-oss/ openSUSE-42.3-Non-Oss
zypper addrepo -f https://mirrors.aliyun.com/packman/openSUSE_Leap_42.3/ aliyun-packman


2.升级软件及内核
zypper update

3. 安装 Docker 包
zypper install docker

4.启动 docker
systemctl start docker
systemctl status docker

5.开机自启动
systemctl enable docker

6. add 到 docker组
/usr/sbin/usermod -aG docker root

7.***拉取 dotnet image
docker pull microsoft/dotnet
docker pull microsoft/dotnet:2.2-aspnetcore-runtime
docker pull microsoft/dotnet:2.1-aspnetcore-runtime

docker pull microsoft/aspnetcore

docker pull microsoft/aspnetcore:2.0

docker pull microsoft/aspnetcore-build

8. # https://blog.csdn.net/woniu211111/article/details/80970560

docker pull redis:4.0


9.https://www.cnblogs.com/li5206610/p/9284647.html
docker pull mysql:5.7.19


10.测试docker安装成功否
docker run hello-world

 

DOTNETCORE

在Docker中部署Asp.net core2.1以及修改发布
https://blog.csdn.net/sd7o95o/article/details/80809734
docker exec 的使用-it操作
https://blog.csdn.net/qq_40081976/article/details/84590119


docker 部署 webapi 示例  (注意这里一定要这样指定端口号)

https://blog.csdn.net/u014690615/article/details/83590412

 

B__________________WebApi  Dockerfile___________________________

# 添加基础镜像

FROM microsoft/dotnet

#容器中系统的工作空间
WORKDIR /app

#拷贝当前文件夹下的文件到容器中系统的工作空间
COPY . /app

#设置Docker容器对外暴露的端口
EXPOSE 64366

#容器中使用 ["dotnet","系统启动的dll"] 来运行应用程序
#使用ENTRYPOINT ["dotnet","系统启动的dll"]
#或使用 CMD ["dotnet","系统启动的dll"]

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

_____________________________________________________

 

 C__________________WebApi NETCORE 镜像制作及发布 ***测试成功***_________________

1.到发布目录建立镜像
/mytest/CoreWebApi/publish # docker build -t webapitestdocker .

2.查看镜像
docker images

3.建立镜像容器
/mytest/CoreWebApi/publish # docker run --name mywebapi -d -p 64366:64366 webapitestdocker

4.测试
curl http://127.0.0.1:64366/api/ts

 ____________________________________________________________________

 

 

----------------------发布控制台程序---------------------------------
#1. Dockerfile 注意此处使用  microsoft/dotnet:2.2-sdk 

FROM microsoft/dotnet:2.2-sdk AS base
WORKDIR /app
COPY . /app

#设置Docker容器对外暴露的端口

#EXPOSE 64366
ENTRYPOINT ["dotnet", "CommandLineSimple.dll"]

#2. 打包数据
docker build -t consoleappimgv2 .

#3. 运行控制台程序
docker run consoleappimgv2

___________________________________________________

 

----------------------发布控制台程序源代码编译---------------------------------
#1. Dockerfile 注意此处使用  microsoft/dotnet:2.2-sdk 

FROM microsoft/dotnet:2.2-sdk AS build
WORKDIR /source
COPY *.csproj .
RUN dotnet restore
COPY . .

FROM build AS publish
RUN dotnet publish -c Release -o /app

FROM microsoft/dotnet:2.2-sdk AS final
WORKDIR /app

#把 publish 镜像别名下的 /app目录 拷贝到 当前目录   详细可以看 [ 第三篇:发布镜像  有实例]
COPY --from=publish /app .
ENTRYPOINT ["dotnet", "CommandLineSimple.dll"]

 

#2 当前目录源码生成镜像
# docker build -t consoleappimage5 .
#3 清理临时镜像 如 Tag:<none>
# docker rmi $(docker images -f "dangling=true" -q)

___________________________________________________

 

open suse 42.3常用软件源(包括阿里云)

 

阿里镜像源,直接在终端安装,首先在终端输入 su 点击回车,输入密码,密码输入时为了安全是不显示的,你输入以后直接回车就可以了。

zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/42.3/oss  openSUSE-42.3-Update-Oss

zypper addrepo -f http://mirrors.aliyun.com/opensuse/update/leap/42.3/non-oss/ openSUSE-42.3-Update-Non-Oss

zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/oss/ openSUSE-42.3-Oss

zypper addrepo -f http://mirrors.aliyun.com/opensuse/distribution/leap/42.3/repo/non-oss/  openSUSE-42.3-Non-Oss

zypper addrepo -f http://mirrors.aliyun.com/packman/openSUSE_Leap_42.3/ aliyun-packman

 

科大镜像源:

zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.3/repo/oss USTC:42.3:OSS

zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/distribution/leap/42.3/repo/non-oss USTC:42.3:NON-OSS

zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.3/oss USTC:42.3:UPDATE-OSS

zypper ar -fc https://mirrors.ustc.edu.cn/opensuse/update/leap/42.3/non-oss USTC:42.3:UPDATE-NON-OSS

 

手动刷新软件源:

sudo zypper ref

 

禁用原有软件源:(可以先禁用所有的软件源,再添加新的软件源)

sudo zypper mr -da

展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部