Important Instructions Used in Dockerfile

Raunak Jain
Updated on 27-Oct-2020 07:42:46

3K+ Views

We all know the importance of dockerfile in creating an efficient and flexible Docker Image. A dockerfile contains a set of instructions that are executed step by step when you use the docker build command to build the docker image. It contains certain instructions and commands that decides the structure of your image, the amount of time taken to build the image, contains instructions related to docker build context, contains information related to the packages and libraries to be installed in the container and many more. Hence, it becomes very important to create an efficient, reusable, clean dockerfile as it ... Read More

Working with Docker Volumes

Raunak Jain
Updated on 27-Oct-2020 07:40:54

1K+ Views

To define Docker Volumes, they are file systems that can be mounted on Docker containers. They help in preserving the data and are independent of the container life cycle. One of the major advantages of Docker Volumes is that it allows the developers to backup their data and also allows easy sharing of file systems among Docker containers. We can easily mount a volume when we launch a Docker container. It is also possible to mount the same volume to different containers and this allows easy sharing of data between them and this can be easily achieved with the use ... Read More

Backup and Restore a Docker Container

Raunak Jain
Updated on 27-Oct-2020 07:38:27

2K+ Views

Docker allows us to automate the process of building and deploying an application. It also allows us to create a packaged environment to run the application which makes it easily portable and lightweight while also allowing us to keep track of the versions. All of these are possible through Docker Containers. It helps in making the applications platform independent.Let’s say we have a docker container running in our machine and we want to take a snapshot or keep a backup of that container so that in case of any emergency, if we want to roll back changes or execute a ... Read More

Get Docker Container IP Address

Raunak Jain
Updated on 27-Oct-2020 07:36:56

4K+ Views

We all know that we can run our application in a packaged environment called container using Docker. When you want containers to talk to each other, the network they create can be assumed to be a bridge network. Run the following command to get a list of networks.sudo docker network lsEach network of containers has a subnet mask and can be used to distribute IP addresses to its containers. This also means that each container in the docker network is assigned an IP address. The default subnet for a docker network is 172.17.0.0/16.Knowing these, we will now see the different ... Read More

Get the Number of True/False Values in an Array Using JavaScript

AmitDiwan
Updated on 26-Oct-2020 11:25:52

2K+ Views

To get the number of true/ false values in an array, the code is as follows −var obj = [    {       isMarried: true    },    {       isMarried: false    },    {       isMarried: true    },    {       isMarried: true    },    {       isMarried: false    } ] function numberOfTrueValues(obj) {    var counter = 0;    for (var index = 0; index < obj.length; index++) {       if (obj[index].isMarried === true) {          counter++;     ... Read More

Understand the find Method to Search for a Specific Record in JavaScript

AmitDiwan
Updated on 26-Oct-2020 11:15:22

477 Views

To fetch a specific record, use find() with some condition.ExampleFollowing is the code −var obj=[    {       studentId:101,       studentName:"John"    },    {       studentId:102,       studentName:"Bob"    },    {       studentId:103,       studentName:"David"    } ] const result = obj.find(    (o) =>    {       return o.studentId === 102    } ); console.log(result);To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo315.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo315.js { studentId: 102, studentName: 'Bob' }

Array Prototype Fill with Object Passes Reference in JavaScript

AmitDiwan
Updated on 26-Oct-2020 11:08:01

178 Views

To fix this, you can use map() in JavaScript.The syntax is as follows −var anyVariableName= new Array(yourSize).fill().map(Object);ExampleFollowing is the code −var arrayOfObject = new Array(5).fill().map(Object); console.log(arrayOfObject);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo311.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo311.js [ {}, {}, {}, {}, {} ]

Stop setInterval After Time or Actions in JavaScript

AmitDiwan
Updated on 26-Oct-2020 11:06:41

2K+ Views

Use some conditions to stop after some time.The below code will stop in half a minute.ExampleFollowing is the code −            Document    var now = new Date().getTime();    var interval = setInterval(function () {       if (new Date().getTime() - now > 30000) {          clearInterval(interval);          return;       }       console.log("working");    }, 2000); To run the above program, save the file name anyName.html(index.html) and right click on the file. Select the option “Open with live server” in VS Code editor.OutputThis will produce the following output −

Sort an Array of Integers Correctly in JavaScript

AmitDiwan
Updated on 26-Oct-2020 11:04:21

380 Views

To sort an array of integers, use sort() in JavaScript.ExampleFollowing is the code −var arrayOfIntegers = [67, 45, 98, 52]; arrayOfIntegers.sort(function (first, second) {    return first - second; }); console.log(arrayOfIntegers);To run the above program, you need to use the following command −node fileName.js.Here, my file name is demo310.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo310.js [ 45, 52, 67, 98 ]

Get Values of Selected Checkboxes using jQuery

AmitDiwan
Updated on 26-Oct-2020 10:56:01

436 Views

Yes, we can use jQuery to get values of selected checkboxes using the concept of input. We have to also use the :checked selector.ExampleFollowing is the code −            Document        Cricket        Listening Music Reading NewsPaper Click Me    $(document).ready(function () {       $("button").click(function () {          $('input[name="checkDemo"]:checked').each(function () {             console.log(this.value);          });       });    }); To run the above program, save the ... Read More

Advertisements