# Docker setup for nextcloud

**URL:** <https://help.nextcloud.com/t/docker-setup-for-nextcloud/242531>\
**Category:** 💻 Development\
**Created:** [March 28, 2026, 11:48am UTC](https://help.nextcloud.com/t/docker-setup-for-nextcloud/242531 "2026-03-28T11:48:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![theking2](https://help.nextcloud.com/user_avatar/help.nextcloud.com/theking2/32/78496_2.png) [@theking2](https://help.nextcloud.com/u/theking2)\
**Post date:** [March 28, 2026, 11:48am UTC](https://help.nextcloud.com/t/docker-setup-for-nextcloud/242531/1 "2026-03-28T11:48:07Z")

</div>

I have Dockerfile:

```auto
# syntax=docker/dockerfile:1

# Source image (update php version when needed)
FROM php:8.3.12-apache

# PHP ini path for upload config
ARG UPLOADS_INI="/usr/local/etc/php/conf.d/uploads.ini"

# Enable mod_rewrite, install dependencies, PHP extensions, and xdebug in one layer
# Clean up apt cache to reduce image size
RUN a2enmod rewrite \
    && apt-get update \
    && apt-get install -y --no-install-recommends libzip-dev libmariadb-dev libfreetype6-dev libjpeg62-turbo-dev libpng-dev \
    && docker-php-ext-install mysqli pdo_mysql gd zip \
    && docker-php-ext-enable mysqli pdo_mysql gd \
    && printf "upload_max_filesize = 128M\npost_max_size = 128M\n" > "${UPLOADS_INI}" \
    && printf "memory_limit = -1\n" >> "${UPLOADS_INI}" \
    && pecl install xdebug-3.4.1 \
    && docker-php-ext-enable xdebug \
    && apt-get purge -y --auto-remove libmariadb-dev \
    && rm -rf /var/lib/apt/lists/* /tmp/pear

USER www-data

```

and compose.yaml:

```auto
name: ${PROJECT_NAME}
networks:
  default:
    name: ${NETWORK_NAME}
    driver: bridge

services:
  server:
    container_name: ${PROJECT_NAME}-web
    extra_hosts:
      host.docker.internal: host-gateway  
    build:
      context: .
    restart: no
    user: "${UID}:${GID}"
    ports: ["9080:80"]
    volumes:
      - ../htdocs/:/var/www/html
      - ../nextcloud-data/:/var/www/html/data
      - ../logs/:/var/www/logs
      - ./xdebug.ini:/usr/local/etc/php/conf.d/xdebug.ini

  db:
    container_name: ${PROJECT_NAME}-db

    image: mariadb
    volumes: ["db:/var/lib/mysql:Z"]
    restart: no
    ports: ["${MARIADB_PORT}:3306"]
    environment:
      - MARIADB_ROOT_PASSWORD=${MARIADB_ROOTPASSWORD}
      - MARIADB_DATABASE=${MARIADB_DATABASE}
      - MARIADB_USER=${MARIADB_USER}
      - MARIADB_PASSWORD=${MARIADB_PASSWORD}
 
volumes:
  db:

```

and .env:

```auto
PROJECT_NAME=nc-dev
NETWORK_NAME=${PROJECT_NAME}-network
MARIADB_PORT=3306
MARIADB_ROOTPASSWORD=guessme
MARIADB_DATABASE=nextcloud
MARIADB_USER=nextcloud
MARIADB_PASSWORD=nextcloud

```

If I start this first thing I get this:

` PHP Fatal error: Uncaught PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'nextcloud.oc_appconfig' doesn't exist in`

which makes sense with an empty database. I can connect to the database but not tables are setup.

---

<div class="post-metadata">

**Author:** ![theking2](https://help.nextcloud.com/user_avatar/help.nextcloud.com/theking2/32/78496_2.png) [@theking2](https://help.nextcloud.com/u/theking2)\
**Post date:** [March 28, 2026, 11:58am UTC](https://help.nextcloud.com/t/docker-setup-for-nextcloud/242531/2 "2026-03-28T11:58:01Z")

</div>

solved. there was a spurious `/config/config.php` from a previous attempt .

So steps to reset the server:

- remove the containers
- remove the volume `nc-dev-db`
- remove the `/config/config.php` file
- remove the `nextcloud-data` folder

 ![image](https://help.nextcloud.com/uploads/default/original/3X/a/1/a19dec2329b1fc3384737c636b30d45aeb400478.png)
