'Bash script set as my container entrypoint executes 2x slower than if it is executed from within the container itself
I have been Docker for quite some time and I now stumbled upon a very strange issue I cannot find the explanation for.
If I run a container for the Dockerfile described below (which has the entrypoint set to /opt/discourse/entrypoint.sh) it will have an execution time of +- 90 seconds. Now the strange thing is, that if I enter this container (using docker exec) and execute this same bash script manually, it has an execution time of +- 45 seconds..
I have tried to see if this is caused by some cashing or anything, so I went ahead and let the entrypoint bash script execute the same commands twice (and timed them twice). It added up to an execution time of 180 seconds, meaning just being a second run will not make it faster.
So just because this bash script is set as the Docker container entrypoint is causing it to be 2x slower.
What on earth could cause a bash script to execute slower if it is set as the container entrypoint? Isn't it executed in the same container anyway under the same environment? Am I missing something about Docker container entrypoints?
Any help would greatly be appreciated!
/opt/discourse/entrypoint.sh:
#!/bin/bash
# shellcheck disable=SC1091
set -o errexit
set -o nounset
set -o pipefail
# set -o xtrace # Uncomment this line for debugging purpose
# Load libraries
. /liblog.sh
info "Compiling assets, this may take a while..."
bundle exec rake assets:precompile
info "Assets compiled!"
Dockerfile:
FROM discourse/base:release
WORKDIR /var/www/discourse
RUN bundle exec rake plugin:pull_compatible_all
# copies over entrypoint.sh script etc.
ADD rootfs /
USER root
ENTRYPOINT ["/opt/discourse/entrypoint.sh"]
CMD ["/opt/discourse/run.sh"]
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
