docker下跑edgex

本文记录了在Ubuntu 20.04上安装Docker和Docker Compose的过程,以及如何运行EdgeX Foundry的基础版本,包括解决登录验证问题和使用国内镜像加速器。作者详细介绍了如何启动不需要验证的EdgeX实例,并添加device-onvif-camera模块,展示了EdgeX的灵活性和可扩展性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

其实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

(Solved)error getting credentials - err: exit status GDBus.Error:org.freedesktop.DBus.Error.ServiceU_Sk1y的博客-CSDN博客

至此,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国内镜像

容器镜像服务 (aliyun.com)

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打包,有悬空镜像

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值