Showing posts with label Docker. Show all posts
Showing posts with label Docker. Show all posts

Sunday, November 15, 2020

How to Change Default Subnet IP Address in Docker

Description: Docker uses default 172.17.0.0/16 subnet for container Networking. If this subnet not available for docker in your environment. You need to change it default subnet. Here I have explained How to change default subnet.

Procedure:

  • First, verify the existing network by using below command 

# docker network inspect bridge


  • Make sure no container is running using docker ps command 

  • Stop docker service using below command 
# systemctl stop docker
  • Create or edit the file using below command 
# vi /etc/docker/daemon.json

Add Lines:

  {
  "default-address-pools":
  [
    {"base":"10.10.0.0/16","size":24}
  ]
}


# systemctl start docker
  • Now verify network using below command and verify by creating new docker container with the name "ServerTechnoLab-Apache"






Sunday, August 2, 2020

Docker Compose

Description: Here I have explained, what is docker compose and how to use it

What is Docker Composer: Docker Composer is use to run multiple container as single service. If you wan to run application and database using single file you can achieve by using single file. 

How to install and run docker composer:

  • Download and install docker composer using below command
# curl -L https://github.com/docker/compose/releases/download/1.21.2/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose
# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# docker-compose --version
docker-compose version 1.21.2, build a133471


  • I have create docker-compose.yml file for word press and mysql database as follow

version: '3.3'

services:
   db:
     image: mysql:5.7
     volumes:
       - db_data:/var/lib/mysql
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: somewordpress
       MYSQL_DATABASE: wordpress
       MYSQL_USER: wordpress
       MYSQL_PASSWORD: wordpress

   wordpress:
     depends_on:
       - db
     image: wordpress:latest
     ports:
       - "8000:80"
     restart: always
     environment:
       WORDPRESS_DB_HOST: db:3306
       WORDPRESS_DB_USER: wordpress
       WORDPRESS_DB_PASSWORD: wordpress
       WORDPRESS_DB_NAME: wordpress
volumes:
    db_data: {}

  • Now run docker-compose to run yml file 
# docker-compose up 
  • Once process will completed you will get output