Build and run an image using the below dockerfile.
Dockerfile1
FROM ubuntu:trusty
ENTRYPOINT ping localhost
Now run the below command to see the processes running in the container.
docker exec -it <container> ps -ef
PID 1 process is running /bin/sh -c ping localhost
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:35 ? 00:00:00 /bin/sh -c ping localhost
root 8 1 0 11:35 ? 00:00:00 ping localhost
root 9 0 0 11:35 pts/0 00:00:00 ps -ef
Now change ONLY the base image to centos:latest.
Modified Dockerfile
FROM centos:latest
ENTRYPOINT ping localhost
Build and run an image using the modified dockerfile. Run the 'docker exec -it ps -ef' command again.
UID PID PPID C STIME TTY TIME CMD
root 1 0 0 11:32 ? 00:00:00 ping localhost
root 8 0 0 11:33 pts/0 00:00:00 ps -ef
But now PID 1 process is running 'ping localhost'
This happen even when ENTRYPOINT is replaced with CMD.
I thought when using the shell form /bin/sh is the process with PID as 1 (both when ENTRYPOINT/CMN being used).
Any ideas why I am seeing a different behaviour just by changing the base image?