DevOps Classroomnotes 23/Nov/2022

Docker Volumes Contd..

  • Generally for stateful application containers, its a good idea to create a VOLUME as part of Dockerfile.
  • Experiment:
    • Create a volume for mysql data and mount that into mysql container
      Preview
      Preview
    • insert some data into it
      Preview
    • delete the container
    • Create a new mysql container and reuse the same volume and verify if the data is present or not.
      Preview
      Preview
      Preview
    • To interact with mysql container Refer Here
    • To create the container we have used docker container run --name mysql-primary -d -P --mount "source=mysql-employee-vol,target=/var/lib/mysql" -e "MYSQL_ROOT_PASSWORD=rootroot" -e "MYSQL_USER=qtdevops" -e "MYSQL_PASSWORD=qtdevops" -e "MYSQL_DATABASE=employee" mysql
    • To login into mysql prompt docker container exec -it mysql-primary mysql -u root -p
    • To create a table
      use employee;
      CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20));
      INSERT INTO authors (id,name,email) VALUES(1,"Vivek","xuz@abc.com");
      INSERT INTO authors (id,name,email) VALUES(2,"Priya","p@gmail.com");
      INSERT INTO authors (id,name,email) VALUES(3,"Tom","tom@yahoo.com");
      select * from authors;
  • Tmpfs mount: This gets mounted to the RAM/memory into container. This is useful only for applications which require preset data to be present in memory

Networking

  • Every container is getting an ip address
  • Docker has a subcommand for network
    Preview
  • lets see what are the networks available
    Preview
  • Two possible Networing options identified
  • Share the same network of docker host to the container
    Preview
  • Create a new network on the docker host and make it available to the containers. Connect the network created by docker host to the network docker host is connected by using a bridge
    Preview
  • Experiment:

    • Created a linux vm and verified network interfaces. we had two interfaces
      • loopback (lo) => 127.0.0.1/localhost
      • eth0
    • We had installed docker on the linux machine and one more interface got created
      • docker0
    • Now we have create a docker container and verified the network interfaces we got two interfaces
      • loopback (lo)
      • eth0
        Preview

Published
Categorized as Uncategorized Tagged

By continuous learner

devops & cloud enthusiastic learner

Leave a Reply

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

Please turn AdBlock off
Animated Social Media Icons by Acurax Responsive Web Designing Company

Discover more from Direct DevOps from Quality Thought

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

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube