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/
image, the same approach can be adapted for
Composer-based projects. To do so, use a different base image (e.g.
php:
) and update the CLI path to match the Composer installation,
typically vendor/
.
Table of contents
Update the Dockerfile to install gosu and Node.js
Extend the Dockerfile to install gosu
, which enables secure user switching, and include the startup.
script to automate the setup process.
FROM martinhelmich/typo3:13.4
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.
#!/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-
:
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:
docker compose down --volumes
rm -rf typo3conf/* typo3temp/* fileadmin/*
Then rebuild and start the containers:
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:
docker logs -f compose-demo-typo3
Expected output includes:
[INFO] No settings.php found, running 'typo3 setup'...
✓ Congratulations - TYPO3 Setup is done.
If the settings.
file is already present, you’ll instead see:
[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:
http://localhost:8080/typo3/
Log in using the credentials you provided in docker-
, for example:
Username: j.doe
Password: Password.1
You should now see the TYPO3 backend dashboard and can start working on your site.