-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use within dockerfile before running another command against now running app #101
Comments
Add wait-for-it to the container and use a docker entrypoint: # DOCKERFILE
FROM <image:tag>
# Add 'wait-for-it' to check upstream availability
COPY wait-for-it.sh /usr/local/bin/wait-for-it
RUN chmod +x /usr/local/bin/wait-for-it
# Add entrypoint script
COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint
RUN chmod +x /usr/local/bin/docker-entrypoint
ENTRYPOINT ["docker-entrypoint"]
CMD [] Then you can do your things inside the entrypoint script: # ENTRYPOINT
#!/bin/bash
set -euo pipefail
# eventually start your server
# wait upstream server availability
wait-for-it <server>:<port> --timeout=300 --strict
# do your things
curl <server>:<port>
# eventually keep your container running
exec tail -f /dev/null This works but it is not optimal. You should design your container to run just one process, in the foreground. |
Thanks for the tip @gioamato, it helped a lot! |
I do this with Docker Compose, by
|
This only works for any environment you use docker-compose with, if you use anything like Fargate or k8s then this is not an option |
I have a scenario where I want to start a server within a container and then, once it's up and running, hit it with a curl command to further configure it. Does anyone have an example of something like this?
The text was updated successfully, but these errors were encountered: