I have a customized image built from a public IBM Db2 image which has an entrypoint doing initializations. To create more than 1 database at startup, I wrote my own init.sh and put it in CMD clause. The COMMAND in 'docker ps' are like:
/var/db2_setup/lib/setup_db2_instance.sh /bin/sh -c /init.sh
The init.sh is
#!/bin/sh
su - db2inst1 << EOF
export PATH=$PATH:/opt/ibm/db2/V11.1/bin
db2 create database DB1
db2 create database DB2
db2 create database DB3
EOF
As I know, the following "/bin/sh -c /init.sh" should be ignored since I checked setup_db2_instance.sh file where there are no codes dealing with param like /bin/sh.
But db2 is successfully initialized and the three DBs are created. Have anyone encountered this or have any reference explaining why this happen?
Relation between entrypoint and command is: command is argument for entrypoint. That's why you see strange command now as /var/db2_setup/lib/setup_db2_instance.sh is probably image's default entrypoint and you are adding /bin/sh -c /init.sh as argument to it by passing by command. So for your case you need to override entrypoint for container instead of command.
So you can put entrypoint: /bin/sh and command: -c /init.sh and result in starting docker will be: /bin/sh -c /init.sh
Or you can just put empty entrypoint and full command in command section or put empty command section and write full command in entrypoint - up to you.