其实docker下把edgex跑起来不难,按照github上的Get Started说明,如下操作就可以了。
release="main" # or "jakarta" for latest wget https://raw.githubusercontent.com/edgexfoundry/edgex-compose/${release}/docker-compose.yml docker-compose up -d
但是对于我而言,无论docker,edgex还是go都不熟悉。
docker大名鼎鼎应用容器引擎,但是没有去深入了解过。
edgex呢,则是这次项目才知道的东西,是一个面向物联网边缘侧设备、服务接入的一个设施。
edgex Foundry is a highly flexible and scalable open source software framework that facilitates interoperablility between device and applications at the loT edge
edgex Foundry是一个高度灵活和可扩展的开源软件框架,可促进loT edge设备和应用程序之间的互操作性
甲方的需求是我司的设备能够接入edgex的device-onvif-camera模块
整个项目是用go语言来做开发的,而我主要使用的是c++。
基于以上原因,这里就做一些笔记,记录从了解到安装到运行起来的过程。
首先,是部署docker环境,操作系统是Ubuntu 20.04。
安装docker和docker compose
我这里是ubuntu的系统,按官网的说明安装就是了
Install Docker Engine on Ubuntu | Docker Documentation
这里安装docker-compse实际并没有用apt-get install docker-compose,而是从github上下载的一个较新的版本,下载docker compose
sudo curl -L https://github.com/docker/compose/releases/download/v2.5.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
因为apt-get下来的docker compose在运行edgex提供的yml文件时会报错,提示版本低,不支持。
额外的,最好做一下如下安装,不然在使用docker-compose时会报错error getting credentials - err
sudo apt install gnupg2 pass
至此,docker和docker compose就安装好了
接下来就是在docker里包edgex先跑起来看看了,按照最上面的Get Started说明,把edgex跑起来,但是。。
这是一个需要登录验证的版本,按提示到这里的说明做相应的设置,但是没有配置出来,
API Gateway - EdgeX Foundry Documentation
于是我先曲线救国,运行一个不需要做登录验证的版本。
edgex的compose提供了多种compose供大家选择。地址在这里edgexfoundry/edgex-compose: EdgeX Foundry Docker Compose release compose files and tools for building EdgeX compose files (github.com)
选择不需要验证的docker-compose-no-secty.yml
将docker-compose-no-secty.yml下载下来,然后
docker-compose -f docker-compose-no-secty.yml up
(如果是第一次运行,会下载很多依赖,我们最好使用阿里云的镜像加速器,如何使用在本篇文章的最后)
启动成功后,在浏览器里访问http://ip:4000/,出现了如下界面
成功。
这里的安装并没有device-onvif-camera的部分,需要我们自己加上
make run no-secty ds-onvif-camera
我们是如何知道添加onvif是ds-onvif-camera标识呢,在compose-builder的makefile里可以找到
# Must have spaces around words for `filter-out` function to work properly.
# Dashes at beginning & end of line ensure space before/after the first/last option on that line
# and don't impact the option list
define OPTIONS
- arm64 no-secty dev app-dev delayed-start -
- zmq-bus mqtt-bus mqtt-broker -
- taf-secty taf-no-secty taf-perf taf-perf-no-secty -
- ds-onvif-camera ds-usb-camera ds-bacnet ds-camera ds-grove ds-modbus ds-mqtt ds-rest ds-snmp ds-virtual ds-llrp ds-coap ds-gpio -
- asc-http asc-mqtt asc-sample asc-metrics as-llrp asc-ex-mqtt -
- modbus-sim -
endef
export OPTIONS
你也可以根据自己的需要添加你想要的微服务,这个也是edgex设计便利的地方
按道理
docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
是因为docker服务没有跑起来,service docker start 一下
使用阿里云的 镜像加速器
docker 设置国内镜像源_whatday的博客-CSDN博客_docker国内镜像
core-command | 2.2.0 | EdgeXFoundry1 | SwaggerHub
删除所有容器
docker rm -f $(docker ps -aq)
删除所有悬空镜像(none)
docker rmi $(docker images | grep "none" | awk '{print $3}')
删除所有镜像(none)
docker rmi $(docker images | awk '{print $3}')
echo $EDGEX_SECURITY_SECRET_STORE
make run no-secty
docker-compose-base.yml docker-compose-no-secty.yml 的
"127.0.0.1:8500:8500"改为"0.0.0.0:8500:8500"
docker save $(docker images | grep -v REPOSITORY | awk 'BEGIN{OFS=":";ORS=" "}{print $1,$2}') -o rancher.tar
可自行尝试该命令:docker images | grep -v REPOSITORY | awk ‘BEGIN{OFS=":";ORS=" "}{print $1,$2}’
用镜像id打包,有悬空镜像