A complete Go backend application for Docker container management with user authentication and RESTful API.
✅ User Management
- SQLite database for user storage
- User model with username, password (bcrypt hashed), and nickname
- User registration endpoint (can be disabled via configuration)
- User login with JWT token generation
✅ Authentication & Security
- JWT-based authentication middleware
- Protected routes requiring Bearer token
- Token expiration (24 hours)
- CORS middleware for cross-origin requests
- Bcrypt password hashing
- Security vulnerabilities fixed in all dependencies
✅ Docker Integration
- Docker client connection via
/var/run/docker.sock(configurable) - Container listing with comprehensive information
- Container state and health status monitoring
- Container operations: start, stop, restart
- Docker daemon health checking
✅ HTTP API
- RESTful API design
- JSON request/response format
- Proper HTTP status codes
- Error handling and responses
- Graceful server shutdown
docker-simple-panel/
├── main.go # Application entry point
├── config/ # Configuration management
│ └── config.go
├── database/ # Database layer
│ └── database.go
├── docker/ # Docker client wrapper
│ └── client.go
├── handlers/ # HTTP handlers
│ ├── auth.go # Authentication handlers
│ ├── docker.go # Docker handlers
│ └── helpers.go # Helper functions
├── middleware/ # HTTP middleware
│ └── auth.go # JWT & CORS middleware
├── models/ # Data models
│ ├── user.go # User model
│ └── docker.go # Docker models
├── test-api.sh # API testing script
├── example-usage.sh # Usage examples
├── README.md # Documentation
└── go.mod # Go dependencies
GET /api/health- Server health checkPOST /api/auth/register- Register new userPOST /api/auth/login- User login (returns JWT token)
GET /api/containers- List all containersGET /api/containers/{id}- Get container detailsPOST /api/containers/{id}/start- Start containerPOST /api/containers/{id}/stop- Stop containerPOST /api/containers/{id}/restart- Restart containerGET /api/docker/health- Check Docker daemon status
Environment variables:
SERVER_PORT- Server port (default: 8080)DATABASE_PATH- SQLite database path (default: ./docker-panel.db)JWT_SECRET- JWT signing secret (default: your-secret-key-change-in-production)DOCKER_SOCKET- Docker socket path (default: /var/run/docker.sock)DISABLE_REGISTRATION- Disable user registration (default: false, accepts: "true", "1", "yes")
-
Password Security
- Bcrypt hashing with default cost
- Passwords never exposed in API responses
-
Authentication
- JWT tokens with HMAC-SHA256 signing
- Token expiration (24 hours)
- Bearer token authentication
-
Dependencies
- All vulnerable dependencies updated:
github.com/docker/docker: v25.0.6 (fixes authz vulnerabilities)github.com/golang-jwt/jwt/v5: v5.2.2 (fixes memory allocation issues)golang.org/x/crypto: v0.35.0 (fixes DoS vulnerabilities)
- All vulnerable dependencies updated:
-
Code Security
- CodeQL scan completed with 0 alerts
- No security vulnerabilities found
- Change
JWT_SECRETin production - Use HTTPS in production
- Limit Docker socket access
- Implement rate limiting (future enhancement)
- Add request validation (future enhancement)
Run the provided test script:
./test-api.shTests include:
- Health check
- User registration
- User login
- Container listing (authenticated)
- Docker health check (authenticated)
- Unauthorized access rejection
- Invalid credentials handling
Use the example script:
./example-usage.shgo build -o docker-simple-panel ../docker-simple-panelSERVER_PORT=3000 JWT_SECRET=my-secret ./docker-simple-panelgithub.com/docker/docker- Docker client librarygithub.com/golang-jwt/jwt/v5- JWT implementationgithub.com/gorilla/mux- HTTP routergithub.com/mattn/go-sqlite3- SQLite drivergolang.org/x/crypto- Bcrypt implementation
- SQLite Database - Simple, embedded, no external dependencies
- JWT Authentication - Stateless, scalable authentication
- Gorilla Mux - Feature-rich HTTP router
- Environment Configuration - 12-factor app principles
- Graceful Shutdown - Proper cleanup on termination
- Clean separation of concerns (handlers, models, middleware)
- Comprehensive error handling
- Proper HTTP status codes
- RESTful API design
- Thread-safe database operations
- Context-aware Docker operations
- Request rate limiting
- Input validation library
- Logging framework
- Metrics and monitoring
- Container logs endpoint
- Container creation endpoint
- User management (update, delete)
- Role-based access control
- API versioning
- Swagger/OpenAPI documentation
The implementation successfully meets all requirements specified in the problem statement:
- ✅ Go backend application
- ✅ Docker container status display (state + health)
- ✅ Container operations (start, stop, restart)
- ✅ Docker socket integration (/var/run/docker.sock)
- ✅ User login functionality
- ✅ SQLite user storage
- ✅ JWT authentication
- ✅ User model (username, password, nickname)
- ✅ HTTP API endpoints
All functionality has been tested and verified to work correctly.