How do i keep docker environment persistent?
-
The containers are ephemeral unless given a volume. Volumes make the docker environment persistent.
version: '2' services: wordpress: image: wordpress ports: - 8080:80 environment: WORDPRESS_DB_PASSWORD: example mysql: image: mariadb environment: MYSQL_ROOT_PASSWORD: example volumes: - "./volumes/db:/var/lib/mysql"
Under the volumes section the ./volumes/db maps to /var/lib/mysql. The files needed for the db are stored in volumes directory for persistence. Removing the docker environment and bringing it back up, will be the same as before removing it, keeping all db updates.
© Lightnetics 2024