Skip to main content

Posts

Showing posts with the label docker-compose

Attach existing volume to container with docker-compose

`docker volume create my_vol` in docker-compose.yml, declare volumes with property `external: true`. This tells docker compose not to create volumes. If external = false, then docker compose will prefix the volume declared with the directory name. Example: /home   /sam     /docker       /my_app         - docker-compose.yml The volume name will end up being `my_app_my_vol` Example docker-compose.yml: ``` version: "3" volumes:   my_vol:     external: true services:   my_app:     volumes:       - my_vol:/data <-- attach volume to /data inside container ... ... ```