-3

I am creating a docker container that will run a minecraft server. (Yes i know, these already exist). And of course i want the world to be saved when the container is turned off.

This is my dockerfile:

FROM anapsix/alpine-java 
COPY ./ /home
CMD ["java","-jar","/home/main.jar"]
EXPOSE 25565

Then i build the container:

docker build -t minecraftdev .

Run the container:

docker run -dp 25565:25565 -v C:/Users/user/server:/home minecraftdev

And then the files in the image, server.properies, the server jar file and EULA.txt is wiped.

Is there another way i don't now of to get the container to store data? And this is without placing the files in the server folder.

double-beep
  • 5,031
  • 17
  • 33
  • 41
  • 2
    The `-v` option replaces _everything_ in the container `/home` directory with the host-directory content, even the jar file in the image. You need to restructure or reconfigure your application to store its data somewhere different from the directory with the jar file. – David Maze Jun 06 '21 at 12:37
  • https://stackoverflow.com/questions/19585028/i-lose-my-data-when-the-container-exits – Marged Jun 06 '21 at 12:38

1 Answers1

0

Thank you for your answers, i was able to fix it by -v C:/Users/user/server/world:/home/world As the world files are stored in that folder, Instead of changing out all the files in the folder as i didn't know -v did.

Minecraft makes the server.jar file and i don't know how to change so it stores all the files in another place.