0

This is I want to achieve - please, don't ask me why :)

I want to run container with two scripts (using Dockerfile): default one + additional script which will execute some operations on container after 1 minute.

EDIT: This is service container so it should be working after executing additional script.

What will be the best way to do that?

Wicia
  • 575
  • 3
  • 9
  • 28

1 Answers1

0

I would setup a single ENTRYPOINT script which combines the two scripts, with a sleep between them. For example:

entrypoint.sh

<execute steps from default script>
sleep 1m
<execute steps from additional script>

And define this as the last step in the Dockerfile:

...
ENTRYPOINT entrypoint.sh
moebius
  • 2,061
  • 11
  • 20
  • This will be service container, so ENTRYPOINT will make it exit after executing script :) - see EDIT. What can we do in this situation? – Wicia Aug 31 '18 at 10:17
  • Is there a process within the container that you are running as a service - for example nginx? In this case, you can run this from `ENTRYPOINT` and it will not exit. If there are no processes (not reccomended), you can always run `tail -f /dev/null` in the last line of your `ENTRYPOINT` to keep the container running. – moebius Aug 31 '18 at 10:25
  • Yes, you are right. Now I have this problem - my ENTRYPOINT script contains following lines: 1) ${SONATYPE_DIR}/start-nexus-repository-manager.sh 2) curl -u admin:admin123 -X GET 'http://localhost:8081/service/rest/v1/repositories' 3) touch ./file First - it is default script running nexus repository manager, two others are additional scripts. Logs are ending with: "Started Sonatype Nexus OSS 3.13.0-01" so after if I should expect logged result from curl / created file? – Wicia Aug 31 '18 at 10:44
  • Ideally there should only be one process running in a container. If you want to run additional scripts it's probably best to run them in a separate container and coordinate them using docker compose. – moebius Aug 31 '18 at 10:56