Kevin Powell - CommunityKP-C
Kevin Powell - Community2y ago
6 replies
MD

Docker not working with SQLite database

I can't get docker to work with my sqlite database and ive tried a bunch of things with changing of files and such and it just doesnt work. My setup is php with apache. Here is my docker-compose file...
version: "3"

services:
  apache:
    build: 
      context: .
      dockerfile: "./Dockerfile"
    # Php site
    volumes:
      - .:/var/www/html
    
    
    # SQL
      - ./database/todoDB.sqlite3:/var/www/html/database/todoDB.sqlite3
  
    ports:
      - "8080:80"
    
    environment:
      - SQLITE_DATABASE_PATH=/var/www/db/todoDb.sqlite3

    networks:
      - backend

    restart: always


networks:
  backend:
    driver: bridge

here is my dockerfile...

FROM debian:latest

RUN apt-get update -y && apt-get install -y apache2 locales-all micro php libapache2-mod-php php-sqlite3

COPY ./000-default.conf /etc/apache2/sites-available/000-default.conf

RUN a2ensite 000-default.conf
#RUN a2dissite 000-default

EXPOSE 80

# Create folder for SQLite
#RUN mkdir /var/www/db

#COPY ./database/todoDB.sqlite3 /var/www/db/todoDB.sqlite3
COPY ./database/todoDB.sqlite3 /var/www/html/todoDB.sqlite3

# Add permissions for writeable database
RUN chmod 777 /var/html/database/todoDB.sqlite3
#RUN chmod 777 /var/www/db
#RUN chmod 777 /var/www/db/todoDB.sqlite3


CMD ["apachectl", "-D", "FOREGROUND"]
Was this page helpful?