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)
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)
----------------------------------------------------
=================
=================
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
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
Nice informative post...Thanks for sharing..Docker and kubernetes Online Training
ReplyDeleteThanks for helping me to understand basic concepts. As a beginner in DevOps, your post helps me a lot.
ReplyDeletebest devops training in chennai | DevOps training in Chennai omr | DevOps training in Chennai with placement
Nice blog with excellent information. Thank you, keep sharing. Kubernetes Training in Hyderabad
ReplyDeleteThis information is really awesome thanks for sharing most valuable information.
ReplyDeleteDocker and Kubernetes Training
Nice Blog. Thanks sharing this information.
ReplyDeleteDocker Training in Hyderabad
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThanks for sharing this information
ReplyDelete<a href=" https://www.visualpath.in/DevOps-docker-kubernetes-training.html ”> Docker Training in Hyderabad</a>
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..
ReplyDeleteDevOps Online Training
DevOps Training in Pune
Awesome Blog!! Thanks for sharing...
ReplyDeleteDocker Training
Docker Training in Hyderabad
Docker Online Training
Kubernetes Online Training
Thanks for sharing Very Use ful Blog..
ReplyDeleteDocker Training in Hyderabad
Docker and Kubernetes Online Training
Docker Training
Docker Online Training
Kubernetes Online Training
Kubernetes Training in Hyderabad
Best Docker and kubernetes training in ameerpet
Docker and Kubernetes Training in Hyderabad
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete
ReplyDeleteNice Article!!!
Docker Training
Docker Online Training
Informative blog. Thank you for sharing with us..
ReplyDeleteDevOps Online Training
ReplyDeleteResources like the one you mentioned here will be very useful to me ! I will post a link to this page on my blog. I am sure my visitors will find that very useful
DevOps Training | Certification in Chennai | DevOps Training | Certification in anna nagar | DevOps Training | Certification in omr | DevOps Training | Certification in porur | DevOps Training | Certification in tambaram | DevOps Training | Certification in velachery
Thanks for one marvelous posting! I enjoyed reading it; you are a great author.
ReplyDeleteGood information. Thanks for sharing with us
oracle training in chennai
oracle training institute in chennai
oracle training in bangalore
oracle training in hyderabad
oracle training
hadoop training in chennai
hadoop training in bangalore
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
ReplyDeletewhich 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
Thank you for taking the time and sharing this information with us. It was indeed very helpful and insightful while being straight forward and to the point.
ReplyDeleteangular js training in chennai
angular js training in velachery
full stack training in chennai
full stack training in velachery
php training in chennai
php training in velachery
photoshop training in chennai
photoshop training in velachery
This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
ReplyDeleteweb designing training in chennai
web designing training in tambaram
digital marketing training in chennai
digital marketing training in tambaram
rpa training in chennai
rpa training in tambaram
tally training in chennai
tally training in tambaram
Nice Post! Thank you for sharing knowledge, it was very good post to update my knowledge and improve my skills. keep blogging.
ReplyDeleteweb designing training in chennai
web designing training in annanagar
digital marketing training in chennai
digital marketing training in annanagar
rpa training in chennai
rpa training in annanagar
tally training in chennai
tally training in annanagar
web designing training in chennai
web designing training in annanagar
digital marketing training in chennai
digital marketing training in annanagar
rpa training in chennai
rpa training in annanagar
tally training in chennai
tally training in annanagar
Thanks for helping me to understand basic concepts. As a beginner in DevOps, your post helps me a lot.
ReplyDeletehadoop training in chennai
hadoop training in omr
salesforce training in chennai
salesforce training in omr
c and c plus plus course in chennai
c and c plus plus course in omr
machine learning training in chennai
machine learning training in omr
Learn how Docker helps developers bring their ideas to life by conquering the complexity of app development.... Docker
ReplyDeleteI really enjoy the blog article.Much thanks again.
ReplyDeletedevops online training
devops training