Completek8s Classroomnotes 07/Jul/2023

Docker Volume

  • Docker has volumes types Refer Here
    • bind mount
    • volume mount
    • tmpfs mount

  • List the volumes and create the mysql contianer, view the volumes after that
  • Now remove the container and view the volumes

  • Lets create a volume called as employee volume
  • I will start a mysql container with the following environmental variables and volume mounted to the container on folder /var/lib/mysql
    • root password MYSQL_ROOT_PASSWORD ==> admin@123
    • database MYSQL_DATABASE => employees
    • user MYSQL_USER => lte
    • user password MYSQL_PASSWORD => admin@123
docker container run -d --name empdb -P -e "MYSQL_ROOT_PASSWORD=admin@123" \
    -e "MYSQL_DATABASE=employees" \
    -e "MYSQL_USER=lte" \
    -e "MYSQL_PASSWORD=admin@123" \
    -v employee:/var/lib/mysql \
    mysql:8


* now lets login into mysql terminal of container and create some tables
docker container exec -it empdb mysql -u lte -p
* Execute the following commands

use employees;
CREATE TABLE Customers
(
  ID int,
  Age int,
  FirstName varchar(20),
  LastName varchar(20)
);
INSERT INTO Customers(ID, FirstName, LastName)
VALUES ('1', 'User', 'Test');
select * from Customers;


* Now lets delete this container

* Now lets create a new container with same volume mounted

docker container run -d --name empdbagain -P -e "MYSQL_ROOT_PASSWORD=admin@123" \
    -e "MYSQL_DATABASE=employees" \
    -e "MYSQL_USER=lte" \
    -e "MYSQL_PASSWORD=admin@123" \
    -v employee:/var/lib/mysql \
    mysql:8
  • Now query for Customers
  • VOLUME instruction in Docker image:
    • While building the docker image if we use the volume instruction with some folder path, volumes will be created if the user doesnot explicitly passes -v or --mount. If -v or –mount are used then data will be used based on the mount passed during container created

Networking in Docker

  • Create a new linux vm and install docker in it
  • execute docker network ls
  • docker implements networking with the help of network drivers Refer Here
  • Docker has came up with specification Container Network Model (CNM) and implemented libnetwork Refer Here whereas there is one more popular container networking specification which is used in kubernetes i.e. Container Network Interface (CNI) Refer Here
  • We will continue this discussion tomorrow
Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Exit mobile version
%%footer%%