Building a docker image doesnt stop because of minecraft server continuing to run
So I have been trying to learn docker for a few days now and set a first goal for me. I want to run a spigot server inside a docker container and later on the road combine that with a BungeeCord network. I have run into problem. My dockerfile runs without problems but once it reaches the point where it starts the minecraft server, the images stops building. I think this is due to the server continuing to run and not returning a code 0 to show docker to keep on running. Am I wrong with my idea, and if not, how can I fix the problem?
Here is my Dockerfile:
FROM ubuntu:14.04 RUN apt-get update RUN apt-get install openjdk-7-jre icedtea-7-plugin -y RUN apt-get install wget -y RUN mkdir mc_server && cd mc_server/ RUN wget http://getspigot.org/spigot18/spigot_server.jar RUN java -Xms1536m -Xmx1536m -Dcom.mojang.eula.agree=true -jar spigot_server.jar nogui
This way the server starts up but docker never finishes building. I hope I made my problem clear.
Replace that last RUN with CMD.
RUN / ADD / .. are used to build the static container environment where you want to run your application in. Everything that happens before running the actual application.
CMD and ENTRYPOINT define what's supposed to happen inside the container once you docker run it. This is where the startup script / call goes for the program.
The result of the Dockerfile is similar to a computer that's shut down but has everything installed on the harddrive including a script that autostarts the application. Turn it on and everything starts to run.
PS: https://hub.docker.com/search/?q=spigot&page=1&isAutomated=0&isOfficial=0&starCount=0&pullCount=0 there are several existing images