We go over a mistake I made when using Docker volumes! I didn't assign a volume
to the two services (mysql database, redis cache) that need to use the volumes we tell Docker Compose to create!
version: '3'
services:
cache:
image: redis:alpine
networks:
- appnet
volumes:
- cachedata:/data
db:
image: mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: secret
MYSQL_DATABASE: homestead
MYSQL_USER: homestead
MYSQL_PASSWORD: secret
networks:
- appnet
volumes:
- dbdata:/var/lib/mysql
networks:
appnet:
driver: bridge
volumes:
dbdata:
driver: local
cachedata:
driver: local
Here we added the volumes:
section to the cache
and db
services.