【以下的问题经过翻译处理】 我正在使用AWS IoT Greengrass将存储在私有ECR仓库中的docker镜像部署到我的Raspberry Pi。部署工作正常。但是,如果我更改部署(即修改它)以运行不同的镜像而不是旧镜像,则旧容器仍会在本地运行。显然,如果我不再将旧容器包含在我的部署中,我希望旧的docker容器停止运行。这仅在关闭RPI并重新启动它时发生。如何确保旧容器立即停止。
我的组件配方如下,我需要更改其中的任何内容吗?
为了完整起见:Docker容器运行一个Python脚本,该脚本进入一个无限循环,每秒打印“Hello,world!”。也许连续循环是问题,但我认为不是,因为我能够通过docker stop
停止容器。
{
"RecipeFormatVersion": "2020-01-25",
"ComponentName": "com.example.MyPrivateDockerComponent_revised",
"ComponentVersion": "1.0.4",
"ComponentType": "aws.greengrass.generic",
"ComponentDescription": "从私有Amazon ECR镜像运行Docker容器的组件(经过修订)。",
"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": {}
}