Dockerfile CMD vs ENTRYPOINT

I had difficulty in understanding the difference between CMD and ENTRYPOINT in Dockerfile before I did the below experiment. Hope this will help someone like me who cannot understand the difference from the documentation or stackoverflow.

Consider the below docker file

[[email protected] 01.BusyboxWithCMD]$ cat Dockerfile
FROM busybox:latest
CMD ["cat", "/etc/passwd"]

Let's build an image and call it busy_cmd_image

[[email protected] 01.BusyboxWithCMD]$ docker build -t busy_cmd_image .
Sending build context to Docker daemon 2.048 kB
Step 1 : FROM busybox:latest
 ---> 2b8fd9751c4c
Step 2 : CMD cat /etc/passwd
 ---> Using cache
 ---> e4df0d0c0d67
Successfully built e4df0d0c0d67

Now, we ...

View comments.

more ...

Random Rationalized

I had a requirement to have random numbers generated in a C application.

#include <stdlib.h>
#include <stdio.h>
int main()
  int i = 0;
  for (i = 0; i < 5; i++) {
    printf("Random number %d  =  %ld\n", i, random());
  return 0;

I ran the code once and saw that random numbers were getting generated.

But to my surprise when I ran the code second time, I saw the same numbers getting printed.

What??? Does it mean random numbers are predictable? If so, why is it called random? Random and Predictable words literally contradicting each other.

But I remember using random.random ...

View comments.

more ...

Generators in Python

One of the few obscure feature of python (for the beginners) is Generators. In this post I would like to share few naive questions I had about generators and the answers I got after understanding them.

Question 1: Are generators something like static variables in C? Say, generateFibonacciNumber() is a generator. First time I call generateFibonacciNumber() and iterate upto value 5, the next time I call generateFibonacciNumber() will it start returning from value 8 when iterated?

This could sound like most dumb question on earth, but honestly I had this question having come from C background.

Answer: No. Generators should ...

View comments.

more ...