Install python
Install pip
Install Virtualenv
yum install python-pip -y
pip install virtualenv
virtualenv helloworld
Windows machine
source helloworld/Scripts/activate
Linux Machine
source helloworld/bin/activate
pip install -r requirements.txt
python application.py
git clone https://github.com/logambigaik/python-mongodb.git
yum install -y docker
service start docker
docker pull mongo:latest
(Ref app.py for html template and application.py for json)
sudo curl -L "https://github.com/docker/compose/releases/download/1.27.3/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
[root@ip-172-31-18-154 ~]# echo $PATH
/usr/local/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
If not worked try,
==============
yum install -y python3-pip
pip3 install docker-compose
ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
docker-compose --version
docker-compose build
#Run the container :
docker-compose up
or docker-compose up -d
and push the image docker-compose push
docker-compose down
docker run --name mongodb -p 27017:27017 -d mongo:latest
docker run --name p1 --link mongodb:mongodb -p 5000:5000 python-mongodb_web:latest
[root@ip-172-31-15-216 python-mongodb]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d956fa5a935b python-mongodb_web:latest "python app.py" 2 minutes ago Up 2 minutes 0.0.0.0:5000->5000/tcp p1
e86f0685cfc1 mongo:latest "docker-entrypoint.sā¦" 3 minutes ago Up 3 minutes 0.0.0.0:27017->27017/tcp mongodb
docker stack deploy --compose-file docker-compose.yml pymongo
For creating network :
docker network create pymongo-bridge --driver=bridge
docker network create pymongo-overlay --driver=overlay
docker swarm join-token worker -> in master and run the belwo token in node
docker swarm join --token SWMTKN-1-0cyoevf5au6nym9047gxr42bzxghps7bdauu2egys3ehvj1z42-4pn23d0n58vebflofbqezxxwt 172.31.32.71:2377
docker-compose push
REMOVED NETWORK NAME IN DOCKERSTACK-COMPOSE.YML
master:
node:
https://docs.docker.com/config/daemon/prometheus/
docker service create --replicas 1 --name my-prometheus \
--mount type=bind,source=/tmp/prometheus.yaml,destination=/etc/prometheus/prometheus.yml \
--publish published=9090,target=9090,protocol=tcp \
prom/prometheus
{
"metrics-addr" : "3.143.242.136:8000",
"experimental" : true
}
# my global config
global:
scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
# scrape_timeout is set to the global default (10s).
# Attach these labels to any time series or alerts when communicating with
# external systems (federation, remote storage, Alertmanager).
external_labels:
monitor: 'codelab-monitor'
# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
rule_files:
# - "first.rules"
# - "second.rules"
# A scrape configuration containing exactly one endpoint to scrape:
# Here it's Prometheus itself.
scrape_configs:
# The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
- job_name: 'prometheus'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
static_configs:
- targets: ['3.143.242.136:9090']
- job_name: 'docker'
# metrics_path defaults to '/metrics'
# scheme defaults to 'http'.
metrics_path: /prometheus
static_configs:
- targets: ['3.143.242.136:8000']
docker service create --replicas 1 --name my-prometheus \
--mount type=bind,source=/tmp/prometheus.yaml,destination=/etc/prometheus/prometheus.yml \
--publish published=9090,target=9090,protocol=tcp \
prom/prometheus