View docker entrypoint output
Asked Answered
R

0

9

I'm configuring an entrypoint to be executed after the container is started:

COPY entrypoint.sh /entrypoint.sh
RUN ["chmod", "+x", "/entrypoint.sh"]

ENTRYPOINT exec /entrypoint.sh

However, I'm not able to see the output of entrypoint.sh execution when docker-compose up.

The only output is:

service exited with code 2

The container is killed so I cannot do docker logs <container_id>

I've tried with docker events command but I don't see any logs related to entrypoint.sh.

I know the entrypoint file has an error, but I'd like to see the output of the execution.

Any ideas?

Rocambole answered 13/3, 2020 at 8:24 Comment(4)
Is it possible it's printing nothing and exiting immediately? The output of the entrypoint is the output of the container and it shouldn't get suppressed. If it's there, don't include a docker-compose up -d option so the container starts in the foreground and you see its output, but I'm guessing you're already doing this.Sharolynsharon
If your shell is GNU bash, "All builtins return an exit status of 2 to indicate incorrect usage". Just specifying ENTRYPOINT ["/entrypoint.sh"] avoids invoking a shell entirely.Sharolynsharon
The other debugging step worth trying is to change this ENTRYPOINT to CMD (permanently), docker-compose run yourcontainer bash, and run /entrypoint.sh by hand at an interactive shell prompt. You won't be process ID 1 but you'll otherwise be inside the container environment, and you can try things like sh -x /entrypoint.sh to trace the script execution.Sharolynsharon
run the same container manually, override the entrypoint to give you a shell, then execute the script manually to see what happens when you run it. If you don't find the error that way, report back with the results.Luanneluanni

© 2022 - 2024 — McMap. All rights reserved.