Run a CLI inside a GreenGrass docker image

0

I have a few greengrass (docker) components that listen to IPC local topics. I now want to test to see if they are actually responding to messages on the local topics so i've written a greengrass_pub application (similar to mosquitto_pub) so i can call: greengrass_pub --topic "local/topic" --payload "{ \"do_some\" : \"stuff\" } "

to check if the other components pick this up.

I have also installed this greengrass_pub application in the docker image, so i should be able to start up another docker image.

Can i startup a docker image to run under the greengrass credentials so I have access to IPC in an interactive way AND have a command prompt where I can try different calls ?

How could I start this up ? ( like a docker interactive (-it) session ? )

note: this is only for development as a tool to check.(i have the greengrass cli installed)

clogwog
질문됨 2년 전334회 조회
2개 답변
0
수락된 답변

Run your docker container as a docker component in Greengrass following the instructions in Use interprocess communication in Docker container components.

Then, from the shell on the host where Greengrass is running, find the container name or id via docker ps and run docker exec -it <container name/id> /bin/sh

Now you can run greengrass_pub --topic "local/topic" --payload "{ \"do_some\" : \"stuff\" } "

Is your command open source? Could you share the repo?

AWS
전문가
답변함 2년 전
0

Thank you for that suggestion Massimiliano,

I have followed the instructions to start the docker that runs the program that listens to ipc already and the container can happily listen to IoT-Core topics so i think the permissions are alright. I've also added the accessControl to allow access to local topics.

{
  "Run": "docker run --name=abcd --cap-add=SYS_PTRACE --runtime=nvidia -e DISPLAY=$DISPLAY --privileged --volume /tmp/.X11-unix:/tmp/.X11-unix --net=host -e NVIDIA_VISIBLE_DEVICES=all -v $HOME/.Xauthority:/root/.Xauthority -v /run/udev/control:/run/udev/control -v /greengrass/v2:/greengrass/v2 -e SVCUID -e AWS_GG_NUCLEUS_DOMAIN_SOCKET_FILEPATH_FOR_COMPONENT -v /dev:/dev -v /sys/firmware/devicetree/base/serial-number:/sys/firmware/devicetree/base/serial-number -v /data:/data -e NVIDIA_DRIVER_CAPABILITIES=compute,utility,graphics   xxxxxxxxxx.dkr.ecr.ap-southeast-2.amazonaws.com/smartdvr:dev3 runscript.sh"
}

runscript.sh looks like:

#!/bin/sh
ret=0
while [ $ret -eq 0 ]; do
	exec /usr/sbin/my_application_that_listens_to_ipc
	ret=$?
	sleep 30
done

when i run docker exec -it abcd /bin/sh

it shows a command prompt ( # ) but as soon as i try to use the command prompt it hangs..

i think that is because it only runs my_application_that_listens_to_ipc .. and i'm not sure that exec can start another 'session' ?

clogwog
답변함 2년 전
  • I had to change the exec to something else, and then it allowed me to docker exec -it into it. thank you

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠