Docker Applications
What is a Docker Space
A Docker application space allows you to deploy any containerized web application. Compared to Gradio and Streamlit which provide preset runtime environments, Docker offers greater flexibility, supporting any programming language and framework for scenarios requiring custom runtime environments.
Create a Docker Space
- Follow the steps in Create Space to open the creation form.
- Select Docker as the SDK Type.
- Choose a platform-provided template (e.g., ChatUI) under Docker Template, or use a custom Dockerfile later.
- Fill in the remaining parameters and click Create Application Space to submit.
Using the ChatUI Template
ChatUI is one of the commonly used Docker templates for quickly deploying a conversational AI interface.
Configuration Steps
- When creating the space, select the Docker SDK type and the ChatUI template.
- The template automatically displays variable and secret fields that need to be filled in.
- In Space Variables, enter the name of the target model that already has an inference service deployed on the platform.
- Fill in any other required configuration fields prompted by the template.
- After creation, the space will automatically initialize and deploy using the ChatUI template.
Note
Using a Custom Dockerfile
If the platform templates do not meet your needs, you can deploy an application with a custom Dockerfile.
Step 1: Clone the Repository
git clone https://<platform-host>/<namespace>/<space-name>
cd <space-name>
Step 2: Create a Dockerfile
Create a Dockerfile defining the build and runtime environment. Here is a Python Flask example:
FROM python:3.11-slim
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
EXPOSE 7860
CMD ["python", "app.py"]
Step 3: Create Application Code
Create requirements.txt:
flask==3.0.0
Create app.py:
from flask import Flask, render_template_string
app = Flask(__name__)
@app.route("/")
def index():
return render_template_string("""
<html>
<head><title>Docker Space Demo</title></head>
<body>
<h1>Hello from Docker Space!</h1>
<p>This application is running in a Docker container on the platform.</p>
</body>
</html>
""")
if __name__ == "__main__":
app.run(host="0.0.0.0", port=7860)
Step 4: Push the Code
git add Dockerfile requirements.txt app.py
git commit -m "Initialize Docker application"
git push origin main
Automatic Build and Deployment
After the code is pushed, the platform automatically triggers the build and deployment process:
- Builds the container image based on the
Dockerfile. - Deploys and starts the container.
- Once the build is complete, the space page displays the application interface.
You can view build logs and running status on the space detail page.
Note
7860. The platform maps this port as the application's access entry point. Ensure your application serves HTTP on this port after startup.