Search code examples
dockerdocker-composetypo3

Why is my docker-compose Website not persisting any data?


I'm new to docker and I've been trying to set up a docker-compose.yaml on Windows 11. So far everything seems to be working, but my typo3 / website container is not persisting any data. Here is my docker-compose.yaml:

version: "1"
networks: 
  lst: 
services: 
  website:
    image: martinhelmich/typo3
    ports: 
      - "80:80"
    links:
      - db
    volumes:
      - ./typo3-persisted-data:/var/www/html/
    environment: 
      TYPO3_ADMIN_USERNAME: "admin"
      TYPO3_ADMIN_PASSWORD: "123"
      TYPO3_DB_HOST: "db"
      TYPO3_DB_NAME: "typo3"
      TYPO3_CONTEXT: "Development"
      TYPO3_DB_USERNAME: "admin"
      TYPO3_DB_PASSWORD: "123"
    networks:
      - lst
  db:
    image: mysql
    ports:
      - "3306:3306"
    environment:
      - MYSQL_ROOT_PASSWORD=123
      - MYSQL_ROOT_HOST=%
      - MYSQL_ROOT_USER=root
      - MYSQL_DATABASE=typo3
    volumes:
      - ./mysql-data:/var/lib/mysql
    networks:
      - lst
  phpmyadmin:
    image: phpmyadmin
    links:
      - db:mysql
    ports:
      - "1234:80"
    environment:
      - MYSQL_ROOT_PASSWORD=123
      - PMA_HOST = db
    networks:
      - lst

When I load my website with this configuration I get an Forbidden You don't have permission to access this resource. error. I've tried using named volumes and can access the page, but no data is being persisted. What am I missing? Thanks a lot in advance!


Solution

  • You must not mount /var/www/html, since typo3 source files reside there.

    You can mount to these directories:

    • /var/www/html/fileadmin
    • /var/www/html/typo3conf
    • /var/www/html/typo3temp
    • /var/www/html/uploads

    You can create a folder for each one you want and bind mount created folders to their respective mount point. The typo3temp folder will be used for temporary things, so not required to bind mound it.

    See martinhelmich/typo3's Dockerfile and sample docker-compose.yml.