Saturday, December 2, 2023

Docker Compose Example 3 (Custom Network)

 






version: "3"

networks:

 ibm:

  driver: bridge

 oracle:

  driver: bridge

services:

  web:

   image: nginx

   container_name: my-nginx

   networks:

    - ibm

   ports:

    - 80

  database:

    networks:

      - oracle

    image: redis

    container_name: my-db



Next run the docker compose command


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

























































































































docker-compose -f example3-docker-compose.yaml down



Let us do another example with volumes

version: '3.8'
services:
  wordpress:
    image: wordpress
    restart: always
    ports:
      - 8080:80
    environment:
      WORDPRESS_DB_HOST: db
      WORDPRESS_DB_USER: exampleuser
      WORDPRESS_DB_PASSWORD: examplepass
      WORDPRESS_DB_NAME: exampledb
    volumes:
      - wordpress:/var/www/html
  db:
    image: mysql:5.7
    volumes:
            - mysqldb:/var/lib/mysql

volumes:
  wordpress:
  mysqldb:









docker-compose -f example8900-dc.yaml up -d



























docker ps







# docker-compose -f example8900-dc.yaml ps







docker images








 





docker volume ls















 ls /var/lib/docker/volumes/root_wordpress/










ls /var/lib/docker/volumes/root_wordpress/_data









docker exec -it d396d243a4ba bash






















Next type env


Variables, which we have created , we will be able to see 

















































Similar you can check for other container

Run that container by using docker exec command

























Now, Login into AWS Cloud and add the port Numbers




























Next step, go back and copy the public IP Address

and browse that by using public ipaddress:8080






































Select the language of your choice


















Give the site url . Enter the details and click on Install WordPress


Next step, you should be able to login with your site url

































You  can create a post, upload media files, Look n feel, comments and other things








Friday, December 1, 2023

Docker Compose -Example 2

 





















vi example2-dc.yml

Write the below code

version: '3'
services:
 web:
  image: nginx:1.19
  container_name: test1
  ports:
   - 86:86

 database:
   image: redis:latest
   container_name: my_db
   ports:
     - "5432:5432"





Giving Permissions.



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


























































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




























































































                                                                                       




















































   






Kubernetes

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