BluesparkLabs / spark

✨ Toolkit to develop, test and run Drupal websites.
MIT License
2 stars 1 forks source link

spark containers:destroy should remove images #41

Closed jameswilson closed 5 years ago

jameswilson commented 5 years ago

The times it makes sense to destroy a container is usually because of some configuration change required inside the container. However if you've cached the container locally, those configuration changes will never be updated because the docker image is cached locally. Therefore spark containers:destroy command should remove cached container images.

The example console command below shows that this is not currently done:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
iuld8_solr          latest              cc5a5023943b        2 months ago        273MB
wodby/drupal-solr   8-6.6-2.4.0         178d2365983f        8 months ago        273MB

$ composer spark containers:destroy
> SPARK_WORKDIR=`pwd` robo --ansi --load-from vendor/bluesparklabs/spark 'containers:destroy'

 Spark ✨ IULD8 — Destroying containers…                                         

 [Droath\RoboDockerCompose\Task\Down] Running Docker-Compose: /usr/local/bin/docker-compose  --file ./docker/docker-compose.drupal8.yml --project-name IULD8 down 
 [Droath\RoboDockerCompose\Task\Down] Running /usr/local/bin/docker-compose  --file ./docker/docker-compose.drupal8.yml --project-name IULD8 down 
Stopping iuld8_solr_1_fb90f2bd53b1 ... done
Removing iuld8_solr_1_fb90f2bd53b1 ... done
Removing network iuld8_default
 [Droath\RoboDockerCompose\Task\Down] Done in 1.817s

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
iuld8_solr          latest              cc5a5023943b        2 months ago        273MB
wodby/drupal-solr   8-6.6-2.4.0         178d2365983f        8 months ago        273MB
jameswilson commented 5 years ago

After patching with d18e2c6f5f2ca66d6c215086e804675c52831ada:

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
iuld8_solr          latest              0e2d171adb8b        17 minutes ago      273MB
wodby/drupal-solr   8-6.6-2.4.0         178d2365983f        8 months ago        273MB

$ composer spark containers:destroy
> SPARK_WORKDIR=`pwd` robo --ansi --load-from vendor/bluesparklabs/spark 'containers:destroy'

 Spark ✨ IULD8 — Destroying containers…                                         

 [Droath\RoboDockerCompose\Task\Down] Running Docker-Compose: /usr/local/bin/docker-compose  --file ./docker/docker-compose.drupal8.yml --project-name IULD8 down  --remove-orphans --rmi all
 [Droath\RoboDockerCompose\Task\Down] Running /usr/local/bin/docker-compose  --file ./docker/docker-compose.drupal8.yml --project-name IULD8 down  --remove-orphans --rmi all
Stopping iuld8_solr_1_83f704e8864f ... done
Removing iuld8_solr_1_83f704e8864f ... done
Removing network iuld8_default
Removing image iuld8_php
Failed to remove image for service php: 404 Client Error: Not Found ("No such image: iuld8_php:latest")
Removing image wodby/drupal-nginx:8-1.13-4.0.2
Failed to remove image for service nginx: 404 Client Error: Not Found ("No such image: wodby/drupal-nginx:8-1.13-4.0.2")
Removing image iuld8_db
Failed to remove image for service db: 404 Client Error: Not Found ("No such image: iuld8_db:latest")
Removing image iuld8_solr
Removing image iuld8_chrome
Failed to remove image for service chrome: 404 Client Error: Not Found ("No such image: iuld8_chrome:latest")
 [Droath\RoboDockerCompose\Task\Down] Done in 2.041s

$ docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
wodby/drupal-solr   8-6.6-2.4.0         178d2365983f        8 months ago        273MB