---
title: "Automate TYPO3 setup using the CLI"
manual: "TYPO3 Explained"
version: "main"
permalink: "https://docs.typo3.org/permalink/t3coreapi:docker-cli-automated-setup@main"
source: "Administration/Docker/AutomateSetup/Index.rst"
modified: "2026-09-14T11:10:56+00:00"
---

# Automate TYPO3 setup using the CLI

This section demonstrates how to fully automate a TYPO3 installation using the CLI
command `typo3 setup`, removing the need to complete the install wizard in the
browser.

This is particularly useful for repeatable local setups, CI pipelines, or scripted
Docker environments.

> [!NOTE]
> While this example uses a classic TYPO3 installation based on the
> `martinhelmich/typo3` image, the same approach can be adapted for
> Composer-based projects. To do so, use a different base image (e.g.
> `php:8.5-apache`) and update the CLI path to match the Composer installation,
> typically `vendor/bin/typo3`.

**Table of contents**

-   [Update the Dockerfile to install gosu and Node.js](https://docs.typo3.org/permalink/t3coreapi:update-the-dockerfile-to-install-gosu-and-node-js@main)
-   [Create a startup script that runs TYPO3 setup](https://docs.typo3.org/permalink/t3coreapi:create-a-startup-script-that-runs-typo3-setup@main)
-   [Define setup parameters in docker-compose.yml](https://docs.typo3.org/permalink/t3coreapi:define-setup-parameters-in-docker-compose-yml@main)
-   [Verify that TYPO3 setup ran successfully](https://docs.typo3.org/permalink/t3coreapi:verify-that-typo3-setup-ran-successfully@main)
-   [Log in to the TYPO3 backend](https://docs.typo3.org/permalink/t3coreapi:log-in-to-the-typo3-backend@main)

## Update the Dockerfile to install gosu and Node.js

Extend the Dockerfile to install `gosu`, which enables secure user switching, and include the `startup.sh` script to automate the setup process.

**Dockerfile**

```docker
FROM martinhelmich/typo3:14.3

USER root

# Install Node.js and gosu (for user switching)
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash - && \
    apt-get install -y nodejs gosu

# Copy the startup script into place
COPY ./startup.sh /usr/local/bin/startup.sh
RUN chmod +x /usr/local/bin/startup.sh

# Let the startup script run as entrypoint (it switches users internally)
ENTRYPOINT ["/usr/local/bin/startup.sh"]

```

## Create a startup script that runs TYPO3 setup

The startup script checks if TYPO3 has already been installed. If not, it runs
the `typo3 setup` CLI command in non-interactive mode using environment
variables defined in Docker Compose.

**startup.sh**

```bash
#!/bin/bash
echo "[INFO] Running custom startup script..."

cd /var/www/html

if [ ! -f typo3conf/system/settings.php ]; then
  echo "[INFO] No settings.php found, running 'typo3 setup'..."
  gosu www-data ./typo3/sysext/core/bin/typo3 setup --no-interaction --force --server-type=apache || true
else
  echo "[INFO] settings.php found, skipping setup."
fi

exec apache2-foreground

```

This script:

-   Detects if TYPO3 has already been installed
-   Runs the CLI-based `setup` command only once
-   Starts Apache in the foreground as required for Docker

> [!NOTE]
> The `gosu` command is used instead of `su` to preserve environment variables
> passed by Docker Compose. Without this, the `typo3 setup` command would not
> receive the necessary database and admin credentials.

> [!TIP]
> If you see this message in the logs:
> `AH00558: apache2: Could not reliably determine the server's fully qualified domain name...`
> you can safely ignore it.

## Define setup parameters in docker-compose.yml

To automate setup, you must provide all required parameters via environment
variables. Add these to the `web` service in your `docker-compose.yml`:

**docker-compose.yml (excerpt)**

```yaml
version: '3.9'

services:
  db:
    image: mariadb:10.6
    container_name: compose-demo-typo3db
    environment:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: db
      MYSQL_USER: db
      MYSQL_PASSWORD: db
    volumes:
      - db_data:/var/lib/mysql

  web:
    build: .
    container_name: compose-demo-typo3
    ports:
      - "8080:80"
    depends_on:
      - db
    volumes:
      - ./fileadmin:/var/www/html/fileadmin
      - ./typo3conf:/var/www/html/typo3conf
      - ./typo3temp:/var/www/html/typo3temp
    environment:
      TYPO3_CONTEXT: Development
      TYPO3_DB_DRIVER: mysqli
      TYPO3_DB_USERNAME: db
      TYPO3_DB_PASSWORD: db
      TYPO3_DB_PORT: 3306
      TYPO3_DB_HOST: db
      TYPO3_DB_DBNAME: db
      TYPO3_SETUP_ADMIN_EMAIL: j.doe@example.com
      TYPO3_SETUP_ADMIN_USERNAME: j.doe
      TYPO3_SETUP_ADMIN_PASSWORD: Password.1
      TYPO3_PROJECT_NAME: TYPO3-Dev

volumes:
  db_data:

```

> [!WARNING]
> If you previously ran this setup, you need to remove existing files and
> volumes before rebuilding to trigger setup again:
>
> ```bash
> docker compose down --volumes
> rm -rf typo3conf/* typo3temp/* fileadmin/*
> ```
>
> Then rebuild and start the containers:
>
> ```bash
> docker compose build --no-cache
> docker compose up -d
> ```

## Verify that TYPO3 setup ran successfully

Check the logs to confirm that the setup script executed on startup:

```bash
docker logs -f compose-demo-typo3
```

Expected output includes:

```text
[INFO] No settings.php found, running 'typo3 setup'...
✓ Congratulations - TYPO3 Setup is done.
```

If the `settings.php` file is already present, you’ll instead see:

```text
[INFO] settings.php found, skipping setup.
```

## Log in to the TYPO3 backend

After the container is running and TYPO3 has been initialized, you can open the
TYPO3 backend in your browser:

```text
http://localhost:8080/typo3/
```

Log in using the credentials you provided in `docker-compose.yml`, for example:

```text
Username: j.doe
Password: Password.1
```

You should now see the TYPO3 backend dashboard and can start working on your site.
