So I have a littlebit confusion in understanding what docker-compose down does.
As per the docs, it says that it removes all the containers, networks, volumes, and images created by up.
But it doesn’t delete volumes and networks if they are defined as external.
Does this means if I write below code, it defines volumes and networks as external?
volumes: wordpress: db: networks: wp_network:
Below is my docker-compose.yml file code. I managed to create it by following documentation and also some tutorials and this is working pretty nicely. As I did docker-compose down, it removed the images and containers. But when I did docker-compose up again, I had my wordpress site data intact and not deleted. Which means the down command ignored the volumes and networks?
version: '3' services: wordpress: image: wordpress depends_on: - db restart: always ports: - 80:80 environment: WORDPRESS_DB_HOST: db WORDPRESS_DB_USER: admin WORDPRESS_DB_PASSWORD: admin WORDPRESS_DB_NAME: wordpressdb volumes: - wordpress:/var/www/html - ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini container_name: wp_site networks: - wp_network db: image: mysql:5.7 restart: always environment: MYSQL_DATABASE: wordpressdb MYSQL_USER: admin MYSQL_PASSWORD: admin MYSQL_ROOT_PASSWORD: root volumes: - db:/var/lib/mysql container_name: wp_mysql networks: - wp_network phpmyadmin: image: phpmyadmin depends_on: - db restart: always ports: - 8080:80 environment: MYSQL_ROOT_PASSWORD: root UPLOAD_LIMIT: 256mb container_name: wp_phpmyadmin networks: - wp_network volumes: wordpress: db: networks: wp_network:
It’s just I am still new to this, I am trying to clear few doubts.