IoT Greengrass Docker deployment: If I change deployment to run a different docker component or different version thereof, the old docker container keeps running locally.

0

Hi,

I am using AWS IoT Greengrass to deploy a docker image that I saved in a private ECR repo to my Raspberry Pi. The deployment works fine. However, if I change the deployment (i.e. revise it) to run a different image and not the old one anymore, the old container still keeps running locally. I obviously want the old docker container to stop if I haven't included it in my deployment anymore. This only happens if I shut down the RPI and restart it. How can Imake sure the old container stops immediately.

My component recipe looks as follows, do I need to change anything therein? For completeness: The Docker container runs a Python script that enters an infinite while loop which prints "Hello, world!" every second. Maybe the continuous loop is the problem but I don't think so as I am able to stop the container through docker stop.

{
	"RecipeFormatVersion": "2020-01-25",
	"ComponentName": "com.example.MyPrivateDockerComponent_revised",
	"ComponentVersion": "1.0.4",
	"ComponentType": "aws.greengrass.generic",
	"ComponentDescription": "A component that runs a Docker container from a private Amazon ECR image revised.",
	"ComponentPublisher": "Amazon",
	"ComponentDependencies": {
		"aws.greengrass.DockerApplicationManager": {
			"VersionRequirement": ">=2.0.0 <2.1.0",
			"DependencyType": "HARD"
		},
		"aws.greengrass.TokenExchangeService": {
			"VersionRequirement": ">=2.0.0 <2.1.0",
			"DependencyType": "HARD"
		}
	},
	"Manifests": [
		{
			"Platform": {
				"os": "all"
			},
			"Lifecycle": {
				"Run": "docker run --sig-proxy=True 242944196659.dkr.ecr.eu-central-1.amazonaws.com/test_repo:latest",
				"Stop": "docker stop $(docker ps -q --filter ancestor=242944196659.dkr.ecr.eu-central-1.amazonaws.com/test_repo:latest)",
				"Destroy": "docker rm $(docker ps -a -q --filter ancestor=242944196659.dkr.ecr.eu-central-1.amazonaws.com/test_repo:latest)"
			},
			"Artifacts": [
				{
					"Uri": "docker:242944196659.dkr.ecr.eu-central-1.amazonaws.com/test_repo:latest",
					"Unarchive": "NONE",
					"Permission": {
						"Read": "OWNER",
						"Execute": "NONE"
					}
				}
			]
		}
	],
	"Lifecycle": {}
}
1 Risposta
1
Risposta accettata

Hello,

The problem is that you're using stop and destroy which I'm not sure where you got those from. Refer to the recipe reference here: https://docs.aws.amazon.com/greengrass/v2/developerguide/component-recipe-reference.html#recipe-format, you should use shutdown as the key to stop the component.

Cheers,

Michael

AWS
ESPERTO
con risposta un anno fa
profile picture
ESPERTO
verificato un mese fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande