现在很多开源软件都采用Docker部署, 开发机器还是用windows多, win10可以用Docker Desktop

win7 下载Docker toolbox 下载地址 https://get.daocloud.io/toolbox/ 下载  v19.03.12

 

运行Docker Termainal, 如果出现下面错误

Error getting IP address: Something went wrong running an SSH command!
command : ip addr show dev eth1
err     : exit status 255

  

 

 

 进入BIOS,找到 Intel Virtualization Technology,这个配置,设置为enabled。

 

运行 Docker Quickstart Terminal ,初次操作Docker需要我们下载boot2Docker镜像,为了节省时间我们可以直接在 (boot2docker下载地址:https://github.com/boot2docker/boot2docker/releases)下载版本相对性的资源

---------------------------------------------------------

boot2docker_19.03.12 网盘链接


链接:https://pan.baidu.com/s/1h6qXJfb1yOiqwgw5HuzZEQ
提取码:69ij
————————————————

在将我们下载的 boot2docker.iso文件复制到C:\Users\Administrator.docker\machine\cache路径下,再次运行Docker Quickstart Terminal。

稍等片刻我们会看到以下结果:

 

 

 

 

为了验证Docker的安装是否成功

可以执行命令 $ docker run hello-world

 

或者可以使用小窗体命令走起

docker version 

 

 

  1. 使用docker pull xxx 命令来拉去mysql镜像。

    如何在docker里面安装MySQL?
  2. 使用docker镜像:(如果本地没有,会自动pull下来)

    docker run -p 3306:3306 --name mymysql -v $PWD/conf:/etc/mysql/conf.d -v $PWD/logs:/logs -v $PWD/data:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d mysql:5.7 。

    如何在docker里面安装MySQL?
    重复启动会提示
  • 使用docker ps 命令, 可以看到容器里已经启动了MySQL。

     如果要导出容器, 用这个

$ docker export c1bd479a5346 > myredis

如果出现 bash: myredis: Permission denied, 检查c:\docker的安装目录是否有写入的权限

停止一个容器,要用docker stop [container id] ,不能用名字, Linux下可以用管道组合

docker ps | grep postgres | awk '{print $1}'

 docker push 可以提交你的镜像到你的dockerHub账户里

先到hub.docker.com 注册一个账号, 获得用户名,再建立一个仓库名
示例: 把一个redis镜像传到自己仓库

docker pull redis:5.0.4
docker tag redis:5.0.4 [用户名]/[仓库名]: redis5.0.4
docker push  [用户名]/[仓库名]: redis5.0.4

 

用以下命令,查看docker容器的资源占用情况:

docker stats --format "table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}"


我们安装一个 https://github.com/WangJunZzz/abp-vnext-pro 的开源软件

开源软件通常会包括一个docker-compose.yaml. 这个可以理解为多个docker 命令的组合的批处理. 用户拿到这个批处理语句,只要运行就能创建出一样的环境

cd d:/[docker-compose.yaml所在的目录]

docker-compose up --build

要注意检查  docker-compose.yaml 里面的端口密码是否和源代码里app.config里的是否一致.

比如这个mysql,对外的端口的3307,docker里的端口是3306, 但代码里是3306,结果老是连不上mysql,

version: '3'
services:
  mysql:
    image: mysql:5.7.26
    # network_mode: "host" # 如果需要容器使用宿主机IP(内网IP),则可以配置此项
    container_name: abp-pro-mysql # 指定容器名称,如果不设置此参数,则由系统自动生成
    restart: always # 设置容器自启模式
    command: mysqld --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci # 设置utf8字符集
    environment:
      - TZ=Asia/Shanghai # 设置容器时区与宿主机保持一致
      - MYSQL_ROOT_PASSWORD=1q2w3E* # 设置root密码
    volumes:
       - /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
    ports:
        - "3307:3306"
    networks:
      - lionAbpPro 

 你可以打开KitMatic 查看Container的Access Url,这个就是外面访问的地址
 

 为了重新创建Mysql数据不会丢,应该把数据和配置文件通过Volumn映射到宿主机上面

    volumes:
       - /etc/localtime:/etc/localtime:ro # 设置容器时区与宿主机保持一致
       - ./dockerData/mysql/data:/var/lib/mysql  #将数据文件夹挂载到主机
       - ./dockerData/mysql/conf:/etc/mysql  #将配置文件夹挂在到主机
       - ./dockerData/mysql/log:/var/log/mysql  将日志文件夹挂载到主机

  

安装完mysql,可以安装DBeaver, 也可以安装NaviCat , 教程如下: https://www.cnblogs.com/522-1997/p/15033758.html 

现在代码都是用EF的Code First, 自然要找到DbMitgrator的项目,改一下connectstring,然后运行一下,生成数据库

abp-vnext-pro-main5\aspnet-core\services\src\Lion.AbpPro.DbMigrator\bin\Debug\net6.0\Lion.AbpPro.DbMigrator.exe

  "ConnectionStrings": {
    "Default": "Data Source=localhost;Port=3307;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
  }

 

RabbitMQ, 我记得之前是可以用Guest登录的 RabbitMQ Management, 但现在不行,登录到容器的CLI,运行下面的命令增加用户

rabbitmqctl  add_user XXX
rabbitmqctl  set_permissions  XXX ".*"  ".*"  ".*"    //赋予XXX读写所有消息队列的权限
rabbitmqctl  set_user_tags XXX administrator    //分配用户组

 

修改修改 HttpApi.Host-> appsettings.json 配置

 

  "ConnectionStrings": {
    "Default": "Data Source=localhost;Port=3307;Database=LionAbpProDB;uid=root;pwd=1q2w3E*;charset=utf8mb4;Allow User Variables=true;AllowLoadLocalInfile=true"
  },
  "Redis": {
    "Configuration": "localhost:6380,password='',defaultdatabase=1"
  },

 

 

 折腾了2天,总算把后端的服务启动起来了. 

 

 

 =======================前端部分==================================

Vben 前端框架需要NodeJS. 但新版本只支持Window8.1 Server 2012以上, win7 只能下12.x的版本

https://nodejs.org/download/release/v12.22.8/ 

 还是说Node.js 我也是装在Docker上呢?

查看nodejs版本号

输入node -v

nodejs自带npm,所以不需要单独下载npm了。

查看npm安装路径

使用命令where npm

查看npm版本号

查看npm版本,输入npm -v

 

通过npm命令进行安装Yarn:

执行命令npm install yarn -g (后面的可选参数-g,g代表global全局安装的意思)

 

执行 npm run dev 就提示 ‘vite’ 不是内部或外部命令,也不是可运行的程序 或批处理文件。

先执行一下 npm i 安装必要的包, 安装到项目目录下的node_modules, 结果提示有一堆错误

49209 warn optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.3.2 (node_modules\fsevents):
49210 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
49211 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
49211 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
49211 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49211 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49212 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-windows-arm64@0.13.15 (node_modules\esbuild-windows-arm64):
49213 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-windows-arm64@0.13.15: wanted {"os":"win32","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
49214 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    win32
49214 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm64
49214 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49214 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49215 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-windows-32@0.13.15 (node_modules\esbuild-windows-32):
49216 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-windows-32@0.13.15: wanted {"os":"win32","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
49217 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    win32
49217 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  ia32
49217 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49217 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49218 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-sunos-64@0.13.15 (node_modules\esbuild-sunos-64):
49219 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-sunos-64@0.13.15: wanted {"os":"sunos","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49220 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    sunos
49220 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49220 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49220 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49221 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-openbsd-64@0.13.15 (node_modules\esbuild-openbsd-64):
49222 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-openbsd-64@0.13.15: wanted {"os":"openbsd","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49223 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    openbsd
49223 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49223 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49223 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49224 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-netbsd-64@0.13.15 (node_modules\esbuild-netbsd-64):
49225 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-netbsd-64@0.13.15: wanted {"os":"netbsd","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49226 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    netbsd
49226 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49226 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49226 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49227 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-ppc64le@0.13.15 (node_modules\esbuild-linux-ppc64le):
49228 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-ppc64le@0.13.15: wanted {"os":"linux","arch":"ppc64"} (current: {"os":"win32","arch":"x64"})
49229 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49229 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  ppc64
49229 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49229 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49230 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-mips64le@0.13.15 (node_modules\esbuild-linux-mips64le):
49231 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-mips64le@0.13.15: wanted {"os":"linux","arch":"mips64el"} (current: {"os":"win32","arch":"x64"})
49232 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49232 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  mips64el
49232 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49232 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49233 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-arm64@0.13.15 (node_modules\esbuild-linux-arm64):
49234 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-arm64@0.13.15: wanted {"os":"linux","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
49235 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49235 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm64
49235 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49235 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49236 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-arm@0.13.15 (node_modules\esbuild-linux-arm):
49237 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-arm@0.13.15: wanted {"os":"linux","arch":"arm"} (current: {"os":"win32","arch":"x64"})
49238 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49238 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm
49238 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49238 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49239 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-64@0.13.15 (node_modules\esbuild-linux-64):
49240 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-64@0.13.15: wanted {"os":"linux","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49241 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49241 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49241 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49241 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49242 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-linux-32@0.13.15 (node_modules\esbuild-linux-32):
49243 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-linux-32@0.13.15: wanted {"os":"linux","arch":"ia32"} (current: {"os":"win32","arch":"x64"})
49244 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    linux
49244 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  ia32
49244 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49244 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49245 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-freebsd-arm64@0.13.15 (node_modules\esbuild-freebsd-arm64):
49246 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-freebsd-arm64@0.13.15: wanted {"os":"freebsd","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
49247 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    freebsd
49247 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm64
49247 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49247 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49248 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-freebsd-64@0.13.15 (node_modules\esbuild-freebsd-64):
49249 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-freebsd-64@0.13.15: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49250 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    freebsd
49250 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49250 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49250 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49251 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-darwin-arm64@0.13.15 (node_modules\esbuild-darwin-arm64):
49252 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-darwin-arm64@0.13.15: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
49253 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
49253 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm64
49253 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49253 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49254 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-darwin-64@0.13.15 (node_modules\esbuild-darwin-64):
49255 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-darwin-64@0.13.15: wanted {"os":"darwin","arch":"x64"} (current: {"os":"win32","arch":"x64"})
49256 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
49256 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  x64
49256 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49256 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49257 warn optional SKIPPING OPTIONAL DEPENDENCY: esbuild-android-arm64@0.13.15 (node_modules\esbuild-android-arm64):
49258 warn notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for esbuild-android-arm64@0.13.15: wanted {"os":"android","arch":"arm64"} (current: {"os":"win32","arch":"x64"})
49259 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    android
49259 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  arm64
49259 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   win32
49259 verbose notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
49260 verbose stack Error: jpegtran-bin@5.0.2 postinstall: `node lib/install.js`
49260 verbose stack Exit status 1
49260 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
49260 verbose stack     at EventEmitter.emit (events.js:314:20)
49260 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
49260 verbose stack     at ChildProcess.emit (events.js:314:20)
49260 verbose stack     at maybeClose (internal/child_process.js:1022:16)
49260 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
49261 verbose pkgid jpegtran-bin@5.0.2
49262 verbose cwd D:\terrywork\abp-vnext-pro-main5\vben271
49263 verbose Windows_NT 6.1.7601
49264 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i"
49265 verbose node v12.22.8
49266 verbose npm  v6.14.15
49267 error code ELIFECYCLE
49268 error errno 1
49269 error jpegtran-bin@5.0.2 postinstall: `node lib/install.js`
49269 error Exit status 1
49270 error Failed at the jpegtran-bin@5.0.2 postinstall script.
49270 error This is probably not a problem with npm. There is likely additional logging output above.
49271 verbose exit [ 1, true ]

用Yarn Install 

npm淘宝镜像
## 镜像使用方法(三种办法任意一种都能解决问题)

#### 1.通过config命令

    npm configsetregistry https://registry.npm.taobao.orgnpm info

    underscore(如果上面配置正确这个命令会有字符串response)

#### 2.命令行指定

npm --registry https://registry.npm.taobao.org info underscore

#### 3.编辑~/.npmrc加入下面内容 (第三种,将配置写死,下次用的时候配置还在)

registry=https://registry.npm.taobao.org

 

还是有错误

error eslint-define-config@1.2.0: The engine "node" is incompatible with this mo
dule. Expected version ">= 16.9.0". Got "12.22.8"
warning eslint-define-config@1.2.0: The engine "pnpm" appears to be invalid.
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this
command.
npm淘宝镜像 后,再用npm install 就安装成功了
added 1975 packages from 869 contributors and audited 1999 packages in 966.576s

181 packages are looking for funding
  run `npm fund` for details

found 66 vulnerabilities (62 moderate, 4 high)
  run `npm audit fix` to fix them, or `npm audit` for details

终于看到界面了

 

 但是输入账号密码,还是登录不了的???  F12看一下,还有个GateWay没有启动

 成功部署了.................... 看一下内存占用, 前后端占了1G, 但是看不到Docker占用的内存

 

 

----查看Docker占用的内存---  docker stats --no-stream

Redis,RabbitMq,mysql总共300m左右

------ 下一步把前后端都放进docker,看能否节约内存呢?

 

  

 

 

 

posted on 2021-12-18 23:16  Gu  阅读(293)  评论(0编辑  收藏  举报