edgexfoundry / device-sdk-go

Owner: Device WG
Apache License 2.0
90 stars 125 forks source link

Problem when using example from device-sdk-go in docker-compose file #1206

Open tntthanh opened 2 years ago

tntthanh commented 2 years ago

Hi everyone, I had built the example of device-sdk-go, had run locally perfectly via make-build execute file, and then pushed it to my docker hub, using it in my docker-compose file, along with other edgex-compose services (e.g: edgex-core-data, edgex-core-metadata,...). I had add "device-simple" into variables: ADD_KNOWN_SECRETS and ADD_SECRETSTORE_TOKENS in secretstore-setup. But, I got this error running the example service with the following log of the errors, please help me solve this:

"... edgex-device-simple | /edgex-init/ready_to_run_wait_install.sh: exec: line 41: /device-simple: not found edgex-device-simple | Tue Aug 9 08:16:58 UTC 2022 Starting /device-simple -cp=consul.http://edgex-core-consul:8500/ --registry --confdir=/res ... edgex-device-simple exited with code 127 ..."

cloudxxx8 commented 2 years ago

ready_to_run_wait_install.sh is expecting your service binary is under the / path. in your case, it should be /device-simple where is your binary located when you build the docker image? please check the Dockerfile.

lenny-goodell commented 2 years ago

also have to have the proper volume mount setup.

lenny-goodell commented 2 years ago

@tntthanh , You are missing the entrypoint and cmd property overrides plus volume mounts, etc: if you must run in secure mode, use device-virtual section here as a template. https://github.com/edgexfoundry/edgex-compose/blob/main/docker-compose.yml#L386

Is there a reason you are doing this with security enabled?

tntthanh commented 2 years ago

@cloudxxx8 I run exactly as source does keep origin, but still got error, I check and try a lots on Dockerfile, but the problem is still not solved: "/edgex-init/ready_to_run_wait_install.sh: exec: line 41: /device-simple: not found". Please help me on Dockerfile or Makefile please, it's so complex on directory structure, I think.

tntthanh commented 2 years ago

Other github sources, for example, for device service mqtt, custom app service, ... (for my example diagnose, built file not in the folder "example" as device-sdk), I can push them to docker hub and run it by docker-compose file very well

cloudxxx8 commented 2 years ago

device-simple is just a sample, and we didn't verify all kinds of deployment scenarios. you should be able to make a simple adjustment to make it work. in this case, you just need to modify the file path.