Docker Deployment
Docker provides a reliable way to deploy NeMo Guardrails with all dependencies packaged in a container. This guide shows you how to build and run NeMo Guardrails using Docker.Prerequisites
- Docker installed on your system (Get Docker)
- NeMo Guardrails source code or configuration files
- Basic familiarity with Docker commands
Official Dockerfile
NeMo Guardrails includes an official Dockerfile that sets up the complete environment:Building the Docker Image
Build the Image
Build the Docker image using the provided Dockerfile:This process may take several minutes as it installs all dependencies.
The Docker image includes the
all-MiniLM-L6-v2 embedding model pre-downloaded for faster startup times.Running the Container
Using Example Configurations
The Docker image comes with example bot configurations. Run with default settings:Using Custom Configurations
Mount your own configuration directory:Docker Compose
For more complex deployments, use Docker Compose: Run with:Environment Variables
Pass environment variables for API keys and configuration:Never hardcode API keys in your Dockerfile or commit them to version control. Use environment variables or secrets management.
Resource Limits
Set resource constraints for the container:Container Management
View Running Containers
View Container Logs
Stop the Container
Access Container Shell
Production Considerations
When deploying to production:- Use Multi-Stage Builds: Optimize image size by using multi-stage builds
- Pin Dependencies: Use specific version tags instead of
latest - Health Checks: Add Docker health check configurations
- Logging: Configure proper logging drivers
- Security: Run as non-root user and scan images for vulnerabilities
Troubleshooting
Container Exits Immediately
Check the logs for errors:Port Already in Use
Use a different host port:Permission Denied for Mounted Volumes
Ensure proper permissions on your host directory:Next Steps
Production Deployment
Learn production best practices
Configuration
Configure your guardrails