Upload File
Upload a file to a container./api/files/:containerID
Path Parameters
Docker container ID (short or full)
Query Parameters
Destination directory path in container
Request Body
File to upload (multipart/form-data)
Validation
- Max File Size: 100 MB
- Filename Restrictions: No path traversal (
..,/) - Container State: Must be running
- Ownership: Must own the container
Response
Success message
Sanitized filename
Full path in container
File size in bytes
Response Example
Upload Implementation
The upload process:- Stream TAR Archive: File is streamed as TAR to avoid memory buffering
- Docker CopyToContainer: Uses Docker SDK’s native copy operation
- Touch Container: Updates last-used timestamp
Download File
Download a file from a container./api/files/:containerID
Path Parameters
Docker container ID
Query Parameters
File path in container (must be a file, not directory)
Response Headers
Content-Disposition:attachment; filename="file.txt"Content-Type:application/octet-streamContent-Length: File sizeX-File-Size: Total size from statX-File-Mode: File permission mode
Response Body
Raw file bytes (binary stream)Error Responses
"container not found"- Invalid container ID"access denied"- Not your container"container is not running"- Container must be running"path parameter required"- Missing path query param"file not found"- File doesn’t exist"path is a directory"- Use/files/listfor directories
List Directory
List files in a container directory./api/files/:containerID/list
Query Parameters
Directory path to list
Response
Requested directory path
Array of file information objects
Total number of files/directories
Response Example
File Object Schema
File or directory name
Full path (basePath + name)
Size in bytes
Unix file mode (e.g., “-rw-r—r—”, “drwxr-xr-x”)
Last modification time (ISO 8601)
True if directory, false if file
Implementation Details
- Uses
ls -lacommand via Docker exec - Parses both GNU ls and busybox ls formats
- Filters out
.and..entries - Handles filenames with spaces
- Compatible with minimal containers (busybox)
Delete File
Delete a file or directory from a container./api/files/:containerID
Query Parameters
File or directory path to delete
Safety Restrictions
Cannot delete system paths:/,/bin,/sbin,/usr,/etc,/var,/lib,/root- Any path under these (except
/home/*)
Response
Success message
Deleted file path
Response Example
Implementation
- Uses
rm -rfcommand via Docker exec - Checks exit code for success/failure
- Recursively deletes directories
Create Directory
Create a directory in a container./api/files/:containerID/mkdir
Query Parameters
Directory path to create
Response
Success message
Created directory path
Response Example
Implementation
- Uses
mkdir -pcommand (creates parent directories) - Checks exit code for verification
Error Handling
All file operation endpoints follow consistent error patterns:Authorization Errors
401 Unauthorized
403 Forbidden
403 System Path
Resource Errors
404 Not Found
404 File Not Found
Validation Errors
400 Bad Request
400 File Too Large
400 Invalid Filename
400 Not Running
400 Directory Error
Best Practices
Upload Large Files
Security
Performance
- List operations: Use specific paths instead of listing root
- Download: Use range requests for large files (if implemented)
- Upload: Compress files before upload when possible
Container State
All file operations require the container to be in
running state. Operations will fail with 400 Bad Request if container is stopped.