docker logs containerid
docker system prune
docker rm containerid
docker rmi -f imagid
chmod 777 directory
chmod 777 file
/etc/wsl.conf
[automount]
root = /
enabled = true
options = "metadata"
Make sure c drive is mounted
ls -la /c
pwd
sudo mkdir prometheus
sudo mkdir prometheus_data
sudo nano docker-compose.yml
version: '3'
networks:
monitor-net:
driver: bridge
volumes:
prometheus_data:
grafana_data:
services:
prometheus:
image: prom/prometheus:latest
container_name: prometheus
volumes:
- ./prometheus/:/etc/prometheus/
- prometheus_data:/prometheus
command:
- '--config.file=/etc/prometheus/prometheus.yml'
- '--storage.tsdb.path=/prometheus'
- '--web.console.libraries=/etc/prometheus/console_libraries'
- '--web.console.templates=/etc/prometheus/consoles'
- '--storage.tsdb.retention=240h'
- '--web.enable-lifecycle'
restart: unless-stopped
expose:
- 9090
ports:
- "9090:9090"
networks:
- monitor-net
blackboxexporter:
image: bitnami/blackbox-exporter:latest
container_name: blackboxexporter
volumes:
- ./blackbox/:/etc/blackbox_exporter/
- /etc/ssl/certs/:/etc/ssl/certs/:ro
command:
- '--config.file=/etc/blackbox_exporter/blackbox.yml'
restart: unless-stopped
expose:
- 9115
ports:
- "9115:9115"
networks:
- monitor-net
grafana:
image: grafana/grafana:latest
container_name: grafana
volumes:
- grafana_data:/var/lib/grafana
environment:
# - GF_SECURITY_ADMIN_USER=please_change_me
# - GF_SECURITY_ADMIN_PASSWORD=please_change_me
- GF_USERS_ALLOW_SIGN_UP=false
restart: unless-stopped
links:
- prometheus:prometheus
expose:
- 3000
ports:
- 3000:3000
networks:
- monitor-net
create a simple Prometheus configuration file in home directory
/home/username
cat <
scrape_configs: - job_name: ‘prometheus’ static_configs: - targets: [‘localhost:9090’] EOF
This tells the Prometheus server to scrape itself on port 9090.
Now let's create a Dockerfile that adds this on top of the prom/prometheus image:
cat <
# Add in the configuration file from the local directory.
ADD prometheus.yml /etc/prometheus/prometheus.yml EOF
Next we can build and run it:
docker build -t prometheus_simple . docker run -p 9090:9090 prometheus_simple
If you visit http://localhost:9090/consoles/prometheus.html you’ll see the Prometheus console!
CTL C to stop prometheus docker images
docker rm prom/prometheus
cd /c/Users/ka0823575/Documents cd /home/kk docker-compose.yml resides here
docker-compose up docker-compose up -d docker-compose down
### Troubleshooting Docker on Windows
Sometimes u have issues with volumes and that could be because of changing the windows logon password, to fix do this
Goto Settings Shared Drives Reset Credential Check C drive Restart Docker
global:
scrape_interval: 10s
evaluation_interval: 10s
scrape_configs:
- job_name: 'prometheus'
static_configs:
- targets: ['localhost:9090','localhost:8000','localhost:3000','localhost:9115']
#scrape_configs:
- job_name: 'blackbox_dns'
metrics_path: /probe
params:
module: [dns_rp_mx]
static_configs:
- targets:
- 8.8.4.4 # Test various public DNS providers are working.
- 8.8.8.8
- 1.0.0.1
- 1.1.1.1
relabel_configs:
- source_labels: [__address__]
target_label: __param_target
- source_labels: [__param_target]
target_label: instance
- target_label: __address__
replacement: localhost:9115
version: '3'
services:
memcache:
image: memcached:latest
ports:
- 11211
networks:
- web
yrslf:
image: img_yrslf
command: uwsgi -i yrslf.ini
volumes:
- .:/yrslf
- /var/run:/var/run
- /tmp:/tmp
ports:
- 8000
logging:
driver: "json-file"
options:
max-size: "5m"
max-file: "2"
environment:
- PYTHONUNBUFFERED=1
extra_hosts:
- "yrslf-mongodb-1:10.88.20.145"
- "yrslf-mongodb-2:10.88.25.75"
- "yrslf-mongodb-3:10.88.28.254"
networks:
- web
nginx:
image: nginx:latest
volumes:
- ./static:/static
- ./nginx.yrslf.conf:/etc/nginx/conf.d/yrslf.conf
- /var/run:/var/run
- /tmp:/tmp
ports:
- 8000:8000
- 80:80
- 443:443
logging:
driver: "json-file"
options:
max-size: "5m"
loadtest:
image: img_yrslf
command: bash -c "locust -f locustfile.py --host=http://yrslf:8000"
volumes:
- .:/yrslf
ports:
- 8089:8089
environment:
- PYTHONUNBUFFERED=1
depends_on:
- yrslf
networks:
- web
networks:
web:
driver: bridge
use bridge driver if you dont want to use sware mode for sware mode use driver overlay ### References
https://nickjanetakis.com/blog/using-wsl-and-mobaxterm-to-create-a-linux-dev-environment-on-windows
https://nickjanetakis.com/blog/setting-up-docker-for-windows-and-wsl-to-work-flawlessly#install-docker-and-docker-compose-within-wsl https://www.linux.com/learn/docker-volumes-and-networks-compose