8

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?

Software Engineer
  • 15,457
  • 7
  • 74
  • 102
Manolo
  • 24,020
  • 20
  • 85
  • 130
  • 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. – David Maze Mar 13 '20 at 10:19
  • 1
    If your shell is GNU bash, ["All builtins return an exit status of 2 to indicate incorrect usage"](https://www.gnu.org/software/bash/manual/html_node/Exit-Status.html#Exit-Status). Just specifying `ENTRYPOINT ["/entrypoint.sh"]` avoids invoking a shell entirely. – David Maze Mar 13 '20 at 10:24
  • 1
    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. – David Maze Mar 13 '20 at 10:25
  • 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. – Software Engineer Mar 13 '20 at 10:45

0 Answers0