Hi,
I have a parent docker image and multiple another images based on the parent image. I only set the ENTRYPOINT
in the parent’s Dockerfile
. There is no ENTRYPOINT
declaration in the child images. Everything works fine, my child images run properly. When I start running a child image then the script that I set in the parent image is executed as I expected.
Now I would like to overwrite the ENTRYPOINT
for one of my child image and run another “business logic” before I continue, so I added a command
element into the docker compose file. According to the documentation this will overwrite the original entrypoint and run my new bash script that is of course, available in the container.
But what I see is the following:
The child image is still executing the original command, defined in the parent’s ENTRYPOINT
and the command I added to the command
element of the compose file became parameters of the entripoint bash script instead of execute it.
Dockerfile
of the basic image:
# parent:0.0.1
FROM alpine:3.21.0
...
COPY container-scripts/entrypoint.sh container-scripts/do-something-else.sh /
ENTRYPOINT ["/entrypoint.sh"]
````
Child image:
# child:0.0.1
FROM parent:0.0.1
...
# no entrypoint declaration
````
compose file:
services:
start-first:
image: child:0.0.1
...
run-after:
image: child:0.0.1
command: ["/do-something-else.sh"]
...
and then the do-something-else.sh:
#!/bin/bash -ue
echo "do something else..."
echo "$@"
exec /entrypoint.sh
But the /do-something-else.sh
became the parameter of the original entripoint.sh
instead of executing the script.
$ docker inspect parent
[
{
"Id": "6399bfc0f0d8ba39e8af41feb50131053dd734535537d47336ef297d21fdb34f",
"Created": "2025-02-03T15:01:50.034149716Z",
"Path": "/entrypoint.sh",
"Args": [
"wait-for-container.sh"
],
...
What I missed here?