1 Answer
- Newest
- Most votes
- Most comments
0
Instead, you can use the docker compose down command in the shutdown lifecycle, which stops and removes containers, but does not remove the images. Here’s how you can modify your lifecycle:
"Lifecycle": {
"run": "docker compose -f {artifacts:path}/docker-compose.yml up",
"shutdown": "docker compose -f {artifacts:path}/docker-compose.yml down"
}
This way, when the component is shut down, the Docker containers will be removed, but the images will be kept intact. When you deploy the component again, it will not conflict with the existing containers.
Relevant content
- AWS OFFICIALUpdated a year ago

@Giovanni Lauria I think docker compose down should remove the images as well? Isn't it?
@Thomas, docker compose down does not remove the images, only the containers. See https://docs.docker.com/reference/cli/docker/compose/down/ as a reference