exec - Execute Commands in ContainersRun shell commands inside your local PrestaShop Enterprise development environment web container.
The exec command provides direct access to running container, allowing you to execute commands within the containerized environment for debugging, maintenance, development tasks, and system administration.
Before running the exec command:
ps-enterprise start# Run specific command in container
ps-enterprise exec "ls -la /var/www/html"
# Open interactive shell in container
ps-enterprise exec --interactive
# Open interactive bash shell using www-data user
ps-enterprise exec --interactive "sudo -u www-data bash"
# Use bash for command execution
ps-enterprise exec --shell=bash "composer install"
| Flag | Short | Description | Required |
|---|---|---|---|
--interactive |
Open interactive shell session | No | |
--shell=<shell> |
Specify shell to use (sh, bash, zsh) | No | |
--static |
Display static logs instead of live streaming | No | |
--help |
-h |
Show command help | No |
# List files in web root
ps-enterprise exec "ls -la /var/www/html"
# Check disk usage
ps-enterprise exec "df -h"
# Find specific files
ps-enterprise exec "find /var/www/html -name '*.php' -type f"
# Check file permissions
ps-enterprise exec "ls -la /var/www/html/app/config/"
# Check PHP version and configuration
ps-enterprise exec "php -v"
ps-enterprise exec "php -i | grep memory_limit"
# Run Composer commands
ps-enterprise exec "composer --version"
ps-enterprise exec "composer install --no-dev"
ps-enterprise exec "composer update specific/package"
# Execute PHP scripts
ps-enterprise exec "php /var/www/html/bin/console cache:clear"
# Connect to database
ps-enterprise exec "mysql -u prestashop -pprestashop prestashop"
# Run specific database queries
ps-enterprise exec "mysql -u prestashop -pprestashop prestashop -e 'SHOW TABLES;'"
# Database maintenance
ps-enterprise exec "mysql -u prestashop -pprestashop prestashop -e 'OPTIMIZE TABLE ps_configuration;'"
# Clear PrestaShop cache
ps-enterprise exec "rm -rf /var/www/html/var/cache/*"
# Check PrestaShop installation
ps-enterprise exec "php /var/www/html/bin/console prestashop:version"
# Run PrestaShop CLI commands (if available)
ps-enterprise exec "php /var/www/html/bin/console module:install mymodule"
# Open interactive shell for extended work
ps-enterprise exec --interactive
# Inside container shell, you can run multiple commands:
$ cd /var/www/html
$ ls -la
$ composer install
$ php bin/console cache:clear
$ exit
# Install development dependencies
ps-enterprise exec "composer install --dev"
# Run code quality tools (if configured)
ps-enterprise exec "vendor/bin/phpcs --standard=PSR12 modules/mymodule/"
ps-enterprise exec "vendor/bin/phpstan analyse modules/mymodule/"
# Run tests (if configured)
ps-enterprise exec "vendor/bin/phpunit tests/"
# Set environment variables for command execution
ps-enterprise exec "export DEBUG=true && php script.php"
# Use environment variables in commands
ps-enterprise exec "echo \$PATH"
# Create files inside container
ps-enterprise exec "echo 'test content' > /tmp/test.txt"
# Copy files within container
ps-enterprise exec "cp /var/www/html/config/config.inc.php /tmp/backup.php"
# Modify file permissions
ps-enterprise exec "chmod 755 /var/www/html/bin/console"
ps-enterprise exec "chown www-data:www-data /var/www/html/var/logs/"
# Check system information
ps-enterprise exec "uname -a"
ps-enterprise exec "cat /etc/os-release"
# Check running processes
ps-enterprise exec "ps aux"
# Check network configuration
ps-enterprise exec "netstat -tulpn"
# Check service status
ps-enterprise exec "service apache2 status"
❌ No running containers found for project
Please run 'ps-enterprise start' first
Solution: Start the environment before executing commands.
❌ Command 'composer' not found in container
Solution:
/usr/local/bin/composer❌ Permission denied: cannot access '/root/.composer'
Solution:
su www-datachmod 755 /path/to/directory❌ Shell 'zsh' not found in container
Solution: Use available shell like bash or sh.
# Start environment and begin debugging
ps-enterprise start
ps-enterprise log & # Monitor logs in background
# Execute debugging commands
ps-enterprise exec "tail -f /var/log/apache2/error.log"
ps-enterprise exec "php -l /var/www/html/modules/mymodule/mymodule.php"
# Install new dependencies
ps-enterprise exec "composer require vendor/package"
# Run development tools
ps-enterprise exec "vendor/bin/phpcs modules/mymodule/"
# Clear caches and test
ps-enterprise exec "rm -rf var/cache/* && php bin/console cache:warmup"
# Database maintenance
ps-enterprise exec "mysql -u prestashop -pprestashop prestashop -e 'OPTIMIZE TABLE ps_log;'"
# File system maintenance
ps-enterprise exec "find /var/www/html/var/logs -name '*.log' -mtime +7 -delete"
# Permission fixes
ps-enterprise exec "chown -R www-data:www-data /var/www/html/var/"
start - Must be run first to have containers available for execlog - Use alongside exec for debugging (monitor logs while executing commands)stop - Stops containers, making exec unavailableexec run inside the containerized environment with the container’s file system, network, and user context.--interactive flag for extended debugging sessions where you need to run multiple commands and explore the container environment.