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": {}
}
Hi Michael, thank you for your answer. It worked!