zoukankan      html  css  js  c++  java
  • Docker构建NetCore基础镜像

    一般制作docker镜像,都是基于网络同道精心打造的镜像。如果想自己构建一个基础的镜像可以通过此次示例来学习。

    学习之路

    下载源码并构建docker镜像 

    下载地址

    build.png

    说明:

    • 需要切换到项目目录下执行构建命令 docker build -t webapi . 不要忘记命令后的 .
    • 构建命令中的 -t webapi 是给构建镜像起别名

    查看制作镜像信息

    PS C:WINDOWSsystem32> docker images
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
    webapi              latest              5462b957a3e2        About an hour ago   161MB

    运行镜像

    PS E:Mydocker> docker run -i -t --name webapi -p 6002:6001  webapi /bin/sh
    / #
    

    说明:

    • -it 开启容器shell终端
    • --name 给容器起别名
    • -p 主机与容器之间的端口映射
    • /bin/sh 运行容器后进入的工作目录

    运行netcore webapi

    / # ls  #查看容器目录
    bin      etc      lib      mnt      opt      publish  run      srv      tmp      var
    dev      home     media    netcore  proc     root     sbin     sys      usr
    / # cd publish   #webapi publish 目录
    /publish # ls
    Google.Protobuf.dll                             System.Data.SqlClient.dll
    Microsoft.Data.Sqlite.dll                       System.Security.Cryptography.ProtectedData.dll
    MySql.Data.dll                                  appsettings.Development.json
    Newtonsoft.Json.dll                             appsettings.json
    Npgsql.dll                                      runtimes
    Oracle.ManagedDataAccess.dll                    web.config
    SQLitePCLRaw.batteries_green.dll                webapi.deps.json
    SQLitePCLRaw.batteries_v2.dll                   webapi.dll
    SQLitePCLRaw.core.dll                           webapi.exe
    SQLitePCLRaw.provider.e_sqlite3.dll             webapi.pdb
    SqlSugar.dll                                    webapi.runtimeconfig.json
    System.Configuration.ConfigurationManager.dll
    

    run.png

    说明:

    • 端口映射后就可以通过主机 localhost:6001 服务webapi站点了
    • 此次webapi示例使用 默认的netcore webapi项目,只是修改了运行示例的接口路径为 api

    镜像源码https://github.com/eric-projects/docker-net-core 

    欢迎打赏

  • 相关阅读:
    mongodb 配置单实例与双实例
    redis 集群 搭建
    memcached 搭建
    公网yum 源地址
    jdk 安装
    activemq 搭建--集群
    zookeeper 安装
    activemq 安装-单点
    rabbitmq 集群
    python——网络编程
  • 原文地址:https://www.cnblogs.com/ctfyfd/p/11706246.html
Copyright © 2011-2022 走看看