docker icon indicating copy to clipboard operation
docker copied to clipboard

Can't use bind volumes

Open Tiritibambix opened this issue 1 year ago • 4 comments

After having the same issue as #111 , I tried using only docker volumes and it worked.

I would like to be able to use volumes like this:

version: '3.7'

services:

  akaunting:
    container_name: akaunting
    image: docker.io/akaunting/akaunting:latest
    build:
      context: .
    ports:
      - 1261:80
    volumes:
      - /PATH/TO/PERSISTENT/DATA/ON/MY/DRIVE/akaunting-data:/var/www/html
    restart: unless-stopped
    env_file:
      - env/run.env
    environment:
      - AKAUNTING_SETUP
    depends_on:
      - akaunting-db

  akaunting-db:
    container_name: akaunting-db
    image: mariadb
    volumes:
      - /PATH/TO/PERSISTENT/DATA/ON/MY/DRIVE/akaunting-db:/var/lib/mysql
    restart: unless-stopped
    env_file:
      - env/db.env

#volumes:
#  akaunting-data:
#  akaunting-db:

How can I achieve that @MohammedAl-Mahdawi ? Thanks for your help.

Tiritibambix avatar May 22 '24 12:05 Tiritibambix

Same issue here

ianc125 avatar Jun 02 '24 01:06 ianc125

same

Mohamed-sobhi95 avatar Sep 04 '24 17:09 Mohamed-sobhi95

Same, that's odd... never had a problem with local volumes... and it's easy to backup/deploy

gizmocuz avatar Dec 11 '24 14:12 gizmocuz

The problem that occurs is that the bind volume isn't mounted during the build process. Thus, when running the container and mounting the (empty) bind volume, the /var/www/html directory is empty. These lines in the Dockerfile basically have no effect but are required: https://github.com/akaunting/docker/blob/77a1312c38ac3ad51be3c5f2528ce8a40598cb0d/Dockerfile#L48-L51

A simple workaround is to initialise the bind mount manually, i.e., execute these commands (don't forget to update the path):

curl -Lo /tmp/akaunting.zip 'https://akaunting.com/download.php?version=latest&utm_source=docker&utm_campaign=developers'
unzip /tmp/akaunting.zip -d <path to your bind volume>
rm -f /tmp/akaunting.zip 

paberr avatar Dec 22 '24 11:12 paberr