The entry point for the docker container tells the docker daemon that it needs to be started when you want to "start" this particular container. Ask the question "what should the container run when it starts a second time?" or "what should the container run after rebooting?"
It is likely that what you are doing follows the same approach you use with the old school initialization mechanisms. Your script "installs" the necessary scripts, and you run your application as a systemd / upstart service, right? If you do this, you should change this to a more "documented" definition.
The entry point for this container should be a script that actually launches your application, rather than configuring it. Let's say you need to install java to run your application. Therefore, in the dockerfile you install the base container to install all the things you need:
FROM alpine:edge RUN apk --update upgrade && apk add openjdk8-jre-base RUN mkdir -p /opt/your_app/ && adduser -HD userapp ADD target/your_app.jar /opt/your_app/your-app.jar ADD scripts/init.sh /opt/your_app/init.sh USER userapp EXPOSE 8081 CMD ["/bin/bash", "/opt/your_app/init.sh"]
Our containers in the company I'm working on, before running the real application in the init.sh script, they extract the configs from the consul (instead of providing a mount point and placing configurations inside the host or embed them in the container). Thus, the script will look something like this:
#!/bin/bash echo "Downloading config from consul..." confd -onetime -backend consul -node $CONSUL_URL -prefix /cfgs/$CONSUL_APP/$CONSUL_ENV_NAME echo "Launching your-app..." java -jar /opt/your_app/your-app.jar
One piece of advice I can give you is (in my very short experience with containers) to handle your containers as if they were stateless after they were provided (all the commands that you ran before the entry point).
Samuel garcΓa
source share