please forgive me my beginners question, I’ve made my homework and did some googling, but still have some challenges.
I’m trying to config some Dockerfile for Zeppelin, which is listening port 8080 and run CURL API right Zeppelin is up and running.
Unfortunately, if I put RUN or CMD command in the end of docker file, like this:
I get an error: curl: (7) Failed to connect to localhost port 8080: Connection refused
But I can successfully RUN the script manually (ssh to the docker and run it there). $ docker exec -itdocker ps -aq /bin/bash $ ./MyScript.sh {"status":"OK","message":"","body":"2F9RFC74N"}
Well, is the container really up and running ? And also your “docker run …” cmd needs to have some “-p 8080:8080” in there as well …
BUT first I’d bring your commands in the right order:
I assume “bin/zeppelin.sh” is the script to launch the app … no ? If so, leave it out and let /usr/bin/tini do the job !
I further assume MyScript.sh is sorely for “testing” the functionality of Zeppelin. You should also leave that out of the Dockerfile. Your app gets started with ENTRYPOINT. So executing the script beforehand will show you nothing
Wouldn’t it make more sense to share everything(!) relevant with us, so we can be the judge what’s relevant to solve your problem.
Since you neither share your complete Dockerfile, nor share your entrypoint scripts, it is impossible to know what causes your problem.
The error message is from inside the container or from the host? Please be more specific with details and provide everything necessary to understand your situation: the complete Dockerfile and your entrypoint script(s), along with the location (host/container?) where the curl problem happens. If it’s on the host, please post your docker run line as well.
Are you certain you need these bind-mounts ?? -v /opt/:/opt/ -v /etc/hadoop:/etc/hadoop -v /etc/alternatives:/etc/alternatives -v /etc/hive:/etc/hive -v /etc/spark:/etc/spark
Especially the “/opt” and “/etc/alternatives” ring some alarm bells. Because here you access links and binaries outside you container … which is against any docker philosophy, a security threat and will most likely lead to an inconsistent/instable app as you mixing binaries/libraries from two different OSs.
If this is really a custom build, make sure all necessary binaries and their dependencies are within the container.
Or use the official images
Good advice, but not pertinent to the original question of why the script can’t access external network (presumably through port 8080) when Dockerfile is run, but can from inside Docker shell after initiated.
Well I’ve seen an “effect” where you explicitely specify the exposed ports inside your Dockerfile (not docker-compose) but the “docker run …” seem to completely ignore these settings.
So I’d suggest you put them in you cmd: docker run ... -p 8080:8080 ...
That did the trick for me …