Search code examples
dockerherokudocker-composedockerfile

What can I use instead of volume for heroku


Heroku documentation says that volumes are not supported by heroku: enter image description here

What should I use instead of volume for heroku?

I have following docker-compose.yml file:

version: '3.9'

services:
    
    db: 
        image: mysql:5.7
        volumes:
            - db_data:/var/lib/mysql
        environment:
            MYSQL_ROOT_PASSWORD: password
            MYSQL_DATABASE: wordpress
            MYSQL_USER: wordpress
            MYSQL_PASSWORD: wordpress
        networks:
            - wpsite
            
    wordpress:
        depends_on:
            - db
        image: wordpress:latest
        ports:
            - '8000:80'
        volumes: ['./:/var/www/html']
        environment: 
            WORDPRESS_DB_HOST: db:3306
            WORDPRESS_DB_USER: wordpress
            WORDPRESS_DB_PASSWORD: wordpress
        networks:
            - wpsite

networks:
    wpsite:
volumes:
    db_data:           

Solution

  • I think there is a misunderstanding between dockerfile and docker-compose.

    • A dockerfile allows to build docker images

    • A compose file allows to define and run multi-container Docker applications

    • You can use volumes in docker-compose.yml as shown in that documentation from Heroku : Heroku documentation

    • You can not use VOLUME instruction in a dockerfile which is described in the following documentation: Docker documentation