Cloud Network

Networking | Support | Tricks | Troubleshoot | Tips

Buymecoffe

Buy Me A Coffee
Showing posts with label Docker. Show all posts
Showing posts with label Docker. Show all posts

Friday, October 29, 2021

How to Install Jenkins with Varies Method | Dockerfile | Image | Compose...

October 29, 2021
How to Install Jenkins with Varies Method | Dockerfile | Image | Compose...

Wednesday, September 2, 2020

How to Setup Monitoring for Docker Containers using Prometheus on Ubuntu 18.04

September 02, 2020
How to Setup Monitoring for Docker Containers using Prometheus on Ubuntu 18.04

 Requirment 

1. docker should be installed

2. docker-compose also be installed


Installation of docker

1.  sudo apt-get install docker.io or sudo apt  install docker.io

2. docker --version

3. sudo apt-get install docker-compose

 

Creating a Configuration files of prometheus

1. create a new file prometheus.yml and copy paste below

sudo nano ~/ prometheus.yml  or sudo nano /etc/prometheus/prometheus.yml

# prometheus.yml
global:
 scrape_interval: 5s
 external_labels:
   monitor: 'my-monitor'
rule_files:
 - 'alert.rules'
scrape_configs:
 - job_name: 'prometheus'
   static_configs:
     - targets: ['your_server_ip:9090']

2. create a new file docker-compose.yml and copy paste below

sudo nano ~/docker-compose.yml or sudo nano /etc/prometheus/docker-compose.yml

# docker-compose.yml
version: '2'
services:
  prometheus:
     image: prom/prometheus:latest
     volumes:
       - ./prometheus.yml:/etc/prometheus/prometheus.yml            
     command:
       - '--config.file=/etc/prometheus/prometheus.yml'
     ports:
       - '9090:9090'

 3. Run the docker compose file

cd /etc/prometheus/ or sudo ~/docker-compose up

sudo docker-compose up

 4. Open browser

http://your_server_ip:9090

 5. Install Node exporter

sudo nano ~/docker-compose.yml or sudo nano /etc/prometheus/docker-compose.yml
 
copy paste at last line
node-exporter:
     image: prom/node-exporter
     ports:
       - '9100:9100'
 sudo nano ~/ prometheus.yml  or sudo nano /etc/prometheus/prometheus.yml
 
copy paste at last line 
- job_name: 'node-exporter'
   static_configs:
     - targets: ['node-exporter:9100'] 

 6. Restart docker-composer

cd /etc/prometheus/ or sudo ~/docker-compose restart

sudo docker-compose restart

7. Install Grafana

sudo nano ~/docker-compose.yml or sudo nano /etc/prometheus/docker-compose.yml

copy paste at last line  

grafana:
     image: grafana/grafana
     user: "0" #[ Execute  id -u in terminal to find the user id from where you are invoking docker compose]
     volumes:
       - ./grafana_db:/var/lib/grafana
     environment:
       - GF_SECURITY_ADMIN_PASSWORD=yourpass
     depends_on:
       - prometheus
     ports:
       - '3000:3000'

 4. Open browser

http://your_server_ip:3000

 

 

Tuesday, September 1, 2020

How to Install Prometheus using Docker on Ubuntu 18.04

September 01, 2020
How to Install Prometheus using Docker on Ubuntu 18.04

1. Create a new file 

sudo nano ~/prometheus.yml
 Add below lines or copy paste into prometheus file
 
# A scrape configuration scraping a Node Exporter and the Prometheus server
# itself.
scrape_configs:
  # Scrape Prometheus itself every 5 seconds.
  - job_name: 'prometheus'
    scrape_interval: 5s
    static_configs:
      - targets: ['localhost:9090']

  # Scrape the Node Exporter every 5 seconds.
  - job_name: 'node'
    scrape_interval: 5s
    static_configs:
      - targets: ['your_server_ip:9100']
 
2. docker run -d -p 9090:9090 -v ~/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus --config.file=/etc/prometheus/prometheus.yml --storage.tsdb.path=/prometheus
3. docker ps
4. http://your_server_ip:9090/status
 
ERROR :- state : UNKNOWN
SOLUTION :- remove  -storage.local.memory-chunks=10000
  
 

Wednesday, November 6, 2019

How to Install Docker Engine - Community (EC) on CentOS 7,8

November 06, 2019
How to Install Docker Engine - Community (EC) on CentOS 7,8

How to Install Docker Engine - Community (EC) on CentOS 7,8 with Latest Version

Uninstall old versions 
Step1 :- sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-engine
or
sudo yum remove docker-ce
sudo rm -rf /var/lib/docker

Install docker ce
Step2 :- sudo dnf install docker-ce-3:18.09.1-3.el7

DNS resolution
Step3 :- sudo systemctl disable firewalld

Start and enable docker daemon
Step4 :- sudo systemctl enable --now docker
or 
sudo systemctl start docker

Verify that Docker EC is installed
Step5 :- sudo docker run hello-world

Adding user to docker group
Step5 :-  sudo usermod -aG docker $USER

Log out and again log in back

Now install the containerd.io package
If you cannot use Docker’s repository to install Docker, you can download the .rpm file for your release and install it manually. You need to download a new file each time you want to upgrade Docker Engine - Community.

Install latest version of docker ce
Step7 :- sudo dnf install docker-ce

Wednesday, October 23, 2019

Docker Interview Question and Answer for Fresher and Experience

October 23, 2019
Docker Interview Question and Answer for Fresher and Experience




  Q :- What is Docker
Ans :- Docker is a platform to run each application isolated and securely. Internally it achieves it by using kernel containerization feature.

 Q :- What is the advantage of Docker over hypervisors?
Ans :- Docker is light weight and more efficient in terms of resource uses because it uses the host underlying kernel rather than creating its own hypervisor.

 Q :- What is Docker Image
Ans :- Docker Image is the source of the docker container. In other words, docker images are used to create containers. It is possible create multiple isolated containers from a single image.

 Q :- What exactly “Containers” are?
Ans :- Containers are usually described as a lightweight virtualization, although it is very different. It is a technology which allows user to run an application in an isolated environment, basically in a container. Those coming from *NIX world can see similarity with chroot-ed application

 Q :-  Is Container technology new?
Ans :- No, it is not. Different variations of containers technology were out there in *NIX world for a long time.
Examples are:
Solaris container (aka Solaris Zones)
FreeBSD Jails
AIX Workload Partitions (aka WPARs)
Linux OpenVZ
Q :- How is Docker different from other container technologies.
Ans :- Well, Docker is a quite fresh project. It was created in the Era of Cloud, so a lot of things are done much nicer than in other container technologies. Team behind Docker looks to be full of enthusiasm, which is of course very good.
I am not going to list all  the features of Docker here but i will mention those which are important to me.
Docker can run on any infrastructure, you can run docker on your laptop or you can run it in the cloud.
Docker has a Container HUB, it is basically a repository of containers which you can download and use. You can even share containers with your applications.
Docker is quite well documented.


 Q :- How exactly containers (Docker in our case) are different from hypervisor virtualization (vSphere)? What are the benefits?
Ans :- To run an application in virtualized environment (e.g. vSphere), we first need to create a VM, install an OS inside and only then deploy the application.
To run same application in docker all you need is to deploy that application in Docker. There is no need of additional OS layer. You just deploy the application with its dependent libraries, the rest (kernel, etc.) is provided by Docker engine.

Another benefit of Docker, from my perspective, is speed of deployment. Lets imagine a scenario:
ACME inc. needs to virtualize application GOODAPP for testing purposes.
Conditions are:
Application should run in an isolated environment.
Application should be available to be redeployed at any moment in a very fast manner.

Solution 1.
In vSphere world what we would usually do, is:
Deploy OS in a VM running on vSphere.
Deploy an application inside OS.
Create a template.
Redeploy the template in case of need. Time of redeployment around 5-10 minutes.
Sounds great! Having app up and running in an hour and then being able to redeploy it in 5 minutes.

Solution 2.
Deploy Docker.
Deploy the app GOODAPP in container.
Redeploy the container with app when needed.
Benefits: No need of deploying full OS for each instance of the application. Deploying a container takes seconds.

Q :- What is the use case for Docker.
Ans :- Well, I think, docker is extremely useful in development environments. Especially for testing purposes. You can deploy and re-deploy apps in a blink of eye.
Also, I believe there are use cases where you can use Docker in production. Imagine you have some Node.js application providing some services on web. Do you really need to run full OS for this?
Eventually, if docker is good or not should be decided on an application basis. For some apps it can be sufficient, for others not.


Q :- What about Docker +VMware partnership? How exactly is VMware going to use Docker?
Ans :- For us, as VMware guys, there is nothing specific. Basically what was announced is that VMware will support running Docker inside VMware VM. In addition, VMware did some big investments into Docker project. You can read Docker Blog article to find out more on this.

 Q :- Wait, Wait. Docker in a VM? Does that even make sense?
Ans :- The answer to this question is simple: Why not?
Imagine a customer that is a long time vSphere user and for their DevOps they want to utilize Docker.
So, why not? They can surely do that.

 Q :-  But if we will run docker inside VM, wouldn’t this affect the performance?
Ans :- There will be some overhead, I guess, if you will run some crazy IO apps. Actually, VMware did a good investigation on this and they posted the results in following article. Interesting reading if you are planing to deploy Docker plus VMware in production.

 Q :-  OK, I want to try Docker, where should I start?
Ans :- First place to start at is on Docker’s official “Try It” page.
If you want to deploy it yourself, check the installation guides page. There is an installation guide for almost every OS and every Cloud provider (not vCoud Air yet)

Q :- I’m a VMware guy, should I care about Docker?
Ans :- My credo is “Knowledge is never useless”, and, I guess, if you are reading this article you are already interested in Docker.
If you are an architect designing environments for customers, Docker is something you should be at least aware of. It is never nice when customer asks something you don’t know about, right?
But, if your daily work is to administer vSphere, work with VMs, create and delete snapshots, troubleshoot issues, in that case I don’t see any reason to deep-dive into Docker, at least not at this point. I would rather say: spend your energy on something more relevant to your work.