Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Docker

   yum install docker
   yum install epel-release -y
   yum install docker-io
   systemctl start docker
   systemctl status docker
   systemctl enable docker
   docker run hello-world
   docker images
   docker info
   docker version
   docker

(one shot easy way, curl -fsSL https://get.docker.com/ | sh systemctl start and enable docker)

  docker pull ubuntu
  docker images
  #docker rmi ubuntu
  docker run ubuntu cat /etc/issue
  #docker run [local image] [command to run into container]
  docker ps -l
  docker start 2201ce5e1124
  docker ps
  docker stop dreamy_mccarthy
  docker ps -l
  docker stop sad_carson
  docker ps -l
  docker ps
  docker run --name myname  ubuntu cat /etc/debian_version
  docker start myname
  docker stats myname
  docker top myname



--------------------------------------------------------------

https://hub.docker.com

example:
docker pull nginx:1.10.2-alpine
docker images
 docker run --name myenginx3 -d -p 82:80 nginx:1.10.2-alpine
 docker ps -a
docker stop myenginx3
 docker ps -a
docker start myenginx3
 docker ps -a
http://localhost/

example:2
docker rm myenginx3
 docker ps -a
login to container--> docker exec -ti myenginx3 /bin/sh
vi /etc/nginx/nginx.conf  (this is inside container )
exit
docker stop myenginx3
docker rm myenginx3
docker run --name myenginx3 -d -v /home/uploads/local.conf:/etc/nginx/nginx.conf:ro -p 82:80 nginx:1.10.2-alpine     (local conf linking to container's conf as ReadOnly)

example:3
docker stop  myenginx3
docker rm  myenginx3
vim /home/uploads/source/index.html --->Hello
docker run --name myenginx3 -d -v /home/uploads/local.conf:/etc/nginx/nginx.conf:ro -v /home/uploads/source:/usr/share/nginx/html:ro -p 82:80 nginx:1.10.2-alpine

Big-example:

vim Dockerfile
FROM nginx:1.10.2-alpine
MAINTAINER hasarangaprasad@gmail.com
COPY ./local.conf /etc/nginx/nginx.conf

same location--> vim local.conf
user  nginx;
worker_processes  1;
error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';
    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

docker build -t zip-alpine:1.0 .   (-t means tag, last dot means find docker file in current location )
(docker ps -a, stop and remove current containers )
Lets create container call  thiismyenginx3 using my image.

docker run --name thiismyenginx3 -d -v /home/uploads/source:/usr/share/nginx/html:ro -p 82:80 zip-alpine:1.0

(if u change html /home/uploads/source/index.html , its updating real time without restart container)



----------------------------------------------------
https://www.tecmint.com/install-docker-and-learn-containers-in-centos-rhel-7-6/



=================
=================
jenkins migrate with docker
http://mmorejon.github.io/en/blog/migrate-jenkins-to-a-docker-container/

 vim Dockerfile 

FROM jenkins:latest
MAINTAINER hasarangaprasad@gmail.com
COPY ./jenkins/ /var/jenkins_home/
USER root
RUN chmod -R 777 /var/jenkins_home/

docker build -t myjen:3.0 .
docker run -d -p 8085:8080 --name jentest myjen:3.0
==========
auto restart with VM is starting
use --restart unless-stopped with docker run command


---


Run 2 containers (ex: app and db)



docker pull mysql
docker pull phpmyadmin/phpmyadmin


docker run --name mysql -e MYSQL_ROOT_PASSWORD=0000 -d mysql

1st way to start app. Mannyally say mysql container's docker ip

docker run --name myadmin -e PMA_HOST=172.17.0.2 -e DB_ENV_MYSQL_ROOT_PASSWORD=0000 -d -p 8081:80 phpmyadmin/phpmyadmin


2nd way to start app: without mentioning db host (docker ip) mannualy

docker run --name myadmin -d --link mysql:db -p 8080:80 phpmyadmin/phpmyadmin
--link takes care of automatically adding the linked container to the /etc/hosts file).
This way you do not have to rely on a specific IP address, be it the host's one or whatever.

Notes:

1.check envr variables : docker exec myadmin env

2.login to app gui, enable mysql plain text password as bellow:
docker exec -it mysql bash
mysql -u root -p 
<0000> 
ALTER USER root IDENTIFIED WITH mysql_native_password BY '0000'; 
exit 
exit
Now access <public IP>:8080 and <public IP>:8180

another ex: https://hub.docker.com/r/phpmyadmin/phpmyadmin/

-----
docker-compose
(The easy way --> build image, run container at once for MULTIPLE services)
otherwise we have to use 'link' to connect each other (docker run --name mywpress --link mymysqk:mysql -p 8080:80 -d wordpress)

install : https://docs.docker.com/compose/install/#install-compose

sudo curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

mkdir /home/folder/
cd /home/folder
vim docker-compose.yml

version: '2'

services:

  wordpress:
    image: wordpress
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_PASSWORD: abc123
  mysql:
    image: mysql:latest
    environment:
      MYSQL_ROOT_PASSWORD: abc123

/usr/local/bin/docker-compose ps
/usr/local/bin/docker-compose up -d
/usr/local/bin/docker-compose ps

goto---> IP:8080 --> you will see WordPress is connected to mysql and , etc ..




Docker Networking

Overlay: Layer2 communication (without complex NAT's)



============
DEFAULT NETWORKS
docker network ls

OVERLAY NRTWORK


Ingress Network



EMBEDDED DNS




-----------------------------------------------
Docker compose another good example. 

I have spring boot app and database connection properties are in application properties file.
https://drive.google.com/open?id=10qmeHuOZHge7iQdf_6Gdoy1WRcsSMJHT

extract this (Docker file and target folder)   

create docker-compose.yml same location. (application properties (url) are overriding with docker environment variables) 
-------------------------------------------------------------

version: '2'

services:
    db:
      image: mysql:5.7
      container_name: sample_db
      volumes:
        - sample_db:/var/lib/mysql
      restart: always
      environment:
        - MYSQL_ROOT_PASSWORD=password
        - MYSQL_DATABASE=test
        - MYSQL_USER=sa
        - MYSQL_PASSWORD=password
      ports:
        - "3306:3306"
    web:
      build:
        context: ./
        dockerfile: Dockerfile
      image: users-mysql
      environment:
        - spring.datasource.url=jdbc:mysql://db:3306/test
      ports:
          - 8086:8086
      depends_on:
          - db

volumes:
    sample_db: {}


/usr/local/bin/docker-compose -f docker-compose.yml up

------------------------------------------------------------------------------------

https://stackoverflow.com/questions/44790923/docker-compose-spring-boot-postgres-connection
------------------------------------------------------------------------------------


Another one with scaling and load balanced (Same java app is used)
===
version: '2'
services:
  web:
    build:
      context: ./
      dockerfile: Dockerfile
    image: users-mysql
    environment:
      - spring.datasource.url=jdbc:mysql://db:3306/test
    ports:
      - 8080
    links:
      - db
    networks:
      - front-tier
      - back-tier

  db:
    image: mysql:5.7
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=password
      - MYSQL_DATABASE=test
      - MYSQL_USER=sa
      - MYSQL_PASSWORD=password
    networks:
      - back-tier

  lb:
    image: dockercloud/haproxy
    ports:
      - 80:80
    links:
      - web
    networks:
      - front-tier
      - back-tier
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

networks:
  front-tier:
    driver: bridge
  back-tier:
    driver: bridge



===


/usr/local/bin/docker-compose -f docker-compose.yml up -d
/usr/local/bin/docker-compose logs
/usr/local/bin/docker-compose scale web=2
/usr/local/bin/docker-compose logs






27 comments:

  1. Great Article About Docker Here you can find some frequently asked
    Docker Interview Questions and Answers with details

    ReplyDelete
  2. Nice blog with excellent information. Thank you, keep sharing. Kubernetes Training in Hyderabad

    ReplyDelete
  3. This information is really awesome thanks for sharing most valuable information.
    Docker and Kubernetes Training

    ReplyDelete
  4. This comment has been removed by the author.

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Thanks for sharing this information
    <a href=" https://www.visualpath.in/DevOps-docker-kubernetes-training.html ”> Docker Training in Hyderabad</a>

    ReplyDelete
  9. This is most informative and also this post most user friendly and super navigation to all posts... Thank you so much for giving this information to me.. 
    DevOps Online Training

    DevOps Training in Pune

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete
  11. This comment has been removed by the author.

    ReplyDelete
  12. After seeing your article I want to say that the presentation is very good and also a well-written article with some very good information
    which is very useful for the readers....thanks for sharing it and do share more posts like this.
    Java training in Chennai

    Java training in Bangalore

    Java training in Hyderabad

    Java Training in Coimbatore

    Java Online Training

    ReplyDelete
  13. Learn how Docker helps developers bring their ideas to life by conquering the complexity of app development.... Docker

    ReplyDelete