Use the postBuild.bash Script
Overview
The postBuild.bash script runs after packages install during the container build.
Use it to configure installed software and set up development tools. Commands run automatically when you rebuild the container.
Use postBuild.bash to configure the container after packages install.
Install software from source, configure JupyterLab, or persist IDE servers. Packages from requirements.txt and apt.txt are already installed at this point.
The script runs as the container user with passwordless sudo access.
You can install system packages, modify permissions, and configure services. Changes persist across container restarts because they’re baked into the image.
The build context is separate from the project.
The script cannot access files in the /project/ directory during build. Install from external sources like GitHub, PyPI, or URLs instead.
Key Concepts
postBuild.bash
Optional bash script in the project root that runs after package installation. Used for final configuration and customization.
Build Order
Container build follows: base image —> preBuild.bash —> package installation —> postBuild.bash —> completed image.
The onStart.bash script runs later, each time a container starts from that image.
Build Context
Separate folder containing only the containerfile, package files, and build scripts. Does not include project files, so the script cannot access /project/ during build.
Passwordless Sudo
The script can run commands with sudo without password prompts. Allows system-level changes during the build.
Edit postBuild.bash in the Desktop App
Step One: Open the script editor.
- Select Project Tab > Project Container > Scripts
- Select postBuild.bash
- Select Edit Script
Step Two: Add your commands to the script.
- Type or paste your bash commands in the editor
- Select Save
Step Three: Rebuild the container to apply changes.
- Select Project Tab > Project Container > Start Build
Success: The container rebuilds with your script changes applied.
Edit postBuild.bash Directly
Step One: Open the script file in your project root.
- Open postBuild.bash in any text editor
Step Two: Add your commands to the script.
- Write bash commands in the file
- Save the file
Step Three: Rebuild the container.
- Select Project Tab > Project Container > Start Build
Success: The container rebuilds with your script changes applied.
What postBuild.bash Can and Cannot Access
The script CANNOT access the following.
- Files in the project (anything in /project/)
- Environment variables defined in variables.env
- Data files or models in your project
The script CAN access the following.
- System package managers (apt, yum, etc.)
- Python package managers (pip, conda)
- External resources (GitHub, PyPI, URLs with curl/wget)
- System directories and files being created during the build
- Build-time environment variables you set in the script itself
- Packages already installed from requirements.txt and apt.txt
Common Mistakes to Avoid
Don’t try to copy files from /project/
This will fail because /project/ doesn’t exist during build:
Don’t reference environment variables from variables.env
These aren’t set during the build:
Workarounds
Install from external sources instead
Download from GitHub or other external locations:
Copy files at runtime instead of build time
Use mounts or copy files after the container starts. See Configure Runtime Settings for details.
Use Cases for postBuild.bash
To persist VS Code, Cursor, or other IDE servers, see the IDE-specific guides.
Add R and Julia kernels to JupyterLab for multi-language notebook support.
Install software not available through package managers.
Compile libraries that need headers from installed packages.
Clean up build artifacts to reduce image size.
Best Practices
Use set -e for error handling
Exit immediately if any command fails:
Add comments to explain complex operations
Document what your script does:
Use absolute paths for file operations
Avoid issues with working directories:
Clean up temporary files
Reduce image size by removing build artifacts:
Test scripts in isolation when possible
Run commands manually in a container to verify they work before adding to scripts.
Related Topics
- Use the preBuild.bash Script - Set up the environment before package installation
- Use the onStart.bash Script - Initialize the running container at each start
- Package Management - Add packages to your container
- Configure Runtime Settings - Set environment variables and mounts
- Use a Custom Container - Use your own base image
- VS Code - Configure VS Code with AI Workbench
- Cursor - Configure Cursor with AI Workbench