- Document common docker-compose commands - Provide configuration examples - Include troubleshooting section - Add environment variables reference table - Include production tips and best practices
159 lines
3.0 KiB
Markdown
159 lines
3.0 KiB
Markdown
# Docker Compose Quick Reference
|
|
|
|
## Quick Start
|
|
|
|
### Full Stack (Server + Agent)
|
|
```bash
|
|
docker-compose up
|
|
```
|
|
Access dashboard: http://localhost:8080
|
|
Login: admin / admin
|
|
|
|
### Server Only
|
|
```bash
|
|
docker-compose up server
|
|
```
|
|
|
|
### Agent Only
|
|
```bash
|
|
SERVER=your-server:8080 docker-compose up agent
|
|
```
|
|
|
|
## Common Commands
|
|
|
|
```bash
|
|
# Start services in background
|
|
docker-compose up -d
|
|
|
|
# Stop all services
|
|
docker-compose down
|
|
|
|
# View logs
|
|
docker-compose logs -f
|
|
|
|
# View logs for specific service
|
|
docker-compose logs -f server
|
|
docker-compose logs -f agent
|
|
|
|
# Restart services
|
|
docker-compose restart
|
|
|
|
# Remove volumes/data
|
|
docker-compose down -v
|
|
|
|
# Rebuild images
|
|
docker-compose build --no-cache
|
|
```
|
|
|
|
## Configuration
|
|
|
|
### Change Server Credentials
|
|
Edit `docker-compose.yml`:
|
|
```yaml
|
|
environment:
|
|
USERNAME: "myuser"
|
|
PASSWORD: "mysecurepassword"
|
|
```
|
|
|
|
### Change Agent Reporting Interval
|
|
```yaml
|
|
environment:
|
|
INTERVAL: "30s" # Report every 30 seconds instead of 15
|
|
```
|
|
|
|
### Set Custom Agent ID
|
|
```yaml
|
|
environment:
|
|
AGENT_ID: "my-machine"
|
|
```
|
|
|
|
### Run Multiple Agents
|
|
```bash
|
|
# Terminal 1: Start server
|
|
docker-compose up server
|
|
|
|
# Terminal 2: Run agent 1
|
|
docker-compose run --name agent1 -e AGENT_ID=machine1 agent
|
|
|
|
# Terminal 3: Run agent 2
|
|
docker-compose run --name agent2 -e AGENT_ID=machine2 agent
|
|
```
|
|
|
|
## Docker Commands
|
|
|
|
### View Running Containers
|
|
```bash
|
|
docker-compose ps
|
|
```
|
|
|
|
### Execute Commands in Container
|
|
```bash
|
|
# Connect to server
|
|
docker-compose exec server sh
|
|
|
|
# View server config
|
|
docker-compose exec server ps aux
|
|
```
|
|
|
|
### View Resource Usage
|
|
```bash
|
|
docker stats
|
|
```
|
|
|
|
## Troubleshooting
|
|
|
|
### Agent can't connect to server
|
|
```bash
|
|
# Check if server is running and healthy
|
|
docker-compose ps
|
|
|
|
# Check server logs
|
|
docker-compose logs server
|
|
|
|
# Check if containers are on same network
|
|
docker network inspect nerd-monitor
|
|
```
|
|
|
|
### Clear Everything and Start Fresh
|
|
```bash
|
|
docker-compose down -v
|
|
docker-compose build --no-cache
|
|
docker-compose up
|
|
```
|
|
|
|
### Port Already in Use
|
|
If port 8080 is already in use, edit `docker-compose.yml`:
|
|
```yaml
|
|
ports:
|
|
- "8090:8080" # Maps host port 8090 to container port 8080
|
|
```
|
|
|
|
## Environment Variables Reference
|
|
|
|
### Server
|
|
| Variable | Default | Description |
|
|
|----------|---------|-------------|
|
|
| ADDR | 0.0.0.0 | Bind address |
|
|
| PORT | 8080 | Server port |
|
|
| USERNAME | admin | Admin username |
|
|
| PASSWORD | admin | Admin password |
|
|
|
|
### Agent
|
|
| Variable | Default | Description |
|
|
| SERVER | server:8080 | Server address |
|
|
| INTERVAL | 15s | Reporting interval |
|
|
| AGENT_ID | (auto) | Agent identifier |
|
|
|
|
## Production Tips
|
|
|
|
1. **Change credentials**: Update USERNAME and PASSWORD in docker-compose.yml
|
|
2. **Use external volumes**: Add volume mounts for data persistence
|
|
3. **Set resource limits**: Uncomment resource limits in docker-compose.yml
|
|
4. **Enable restart policies**: Already set to `unless-stopped`
|
|
5. **Use environment files**: Create `.env` file for sensitive data:
|
|
```bash
|
|
USERNAME=myuser
|
|
PASSWORD=mysecurepass
|
|
```
|
|
Then in docker-compose.yml: `env_file: .env`
|