Thursday, November 30, 2023

Docker Compose

Docker Compose is used to run multiple containers as a single service. For example, suppose you had an application which required NGNIX and MySQL, you could create one file which would start both the containers as a service without the need to start each one separately




Docker compose reads configuration data from a YAML file .
The key difference between docker run versus docker-compose is that docker run is entirely command line based, while docker-compose reads configuration data from a YAML file.

The second major difference is that docker run can only start one container at a time, while docker-compose will configure and run multiple.


Docker Compose Installation






First step is to check if Docker is installed or Not . We can check by using the below command. If Docker is not installed, than you need to install it





InstallCompose
Step 1 − Download the necessary files from github using the following command 
sudo curl -L "https://github.com/docker/compose/releases/download/1.10.0-rc2/dockercompose-$(uname -s) -$(uname -m)" -o /home/demo/docker-compose





Then, Run the below Command.


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









Now, we need to give permissions, for that run the below command




Next, we need to provide execute privileges to the downloaded Docker Compose file, using the following command

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











We can then use the following command to see the compose version.

docker-compose version 




YAML: Yet   Another/Ain't   Mark Up Language

It is basically a key value pair.













































vi example1-docker-compose.yaml


version: '3'
services:
  web:
   image: nginx
   container_name: demo






Now let’s run our Docker Compose file using the following command 

docker-compose -f example1-docker-compose.yaml up -d




























































































                                                                                       




















































   






Wednesday, November 29, 2023

Docker Installation File Java Project

First pull the source code  using 

git pull url 

Note: We always need to give jar files, never give source code in git hub.






























































Now, open the Dockerfile by using cat command















Now, let us build without copying the source code








































docker build -f Dockerfile . --tag sprin-boot:2.5.5  























Now, run docker run command

docker run -dit --name  hello -p 8080:8080 sprin-boot:2.5.5
































Go to AWS Account
























Browse with public IP Address






























We can share this url so that others can also join

















Now we need to tag


































If u are not able to push then tag that image

docker tag sprin-boot:2.5.5 uday9287/dockerhub:sprin-bootimagepush

Then run the below push command

docker push uday9287/dockerhub:sprin-bootimagepush














































Now, if this we can confirm that , we never share the source code 

Complete Commands
















Kubernetes

Prerequisites We assume anyone who wants to understand Kubernetes should have an understating of how the Docker works, how the Docker images...