forked from docker-archive/minecraft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
42 lines (34 loc) · 1.71 KB
/
Dockerfile
File metadata and controls
42 lines (34 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# Minecraft 1.11 Dockerfile - Example with notes
# Use the offical Debian Docker image with a specified version tag, Stretch, so not all
# versions of Debian images are downloaded.
FROM openjdk:18-slim
LABEL author="Alexander Kopper <github@knospi.com>"
# Simple utility for download a specific version of the minecraft server.jar
ENV MINECRAFT_UTILITY https://github.com/marblenix/minecraft_downloader/releases/download/20190517-d23712d/minecraft_downloader_linux
# Version of minecraft to download
ARG MINECRAFT_VERSION=1.19.0
ENV MINECRAFT_VERSION=${MINECRAFT_VERSION}
ENV MINECRAFT_MAX_MEMORY=2G
# Use APT (Advanced Packaging Tool) built in the Linux distro to download Java, a dependency
# to run Minecraft.
# First, we need to ensure the right repo is available for JRE 8
# Then we update apt
# Then we pull in all of our dependencies,
# Finally, we download the correct .jar file using wget
# .jar file fetched from the official page https://minecraft.net/en-us/download/server/
RUN apt update; \
apt install -y curl; \
curl -sL "${MINECRAFT_UTILITY}" -o minecraft_downloader; \
chmod +x ./minecraft_downloader; \
./minecraft_downloader -o minecraft_server_${MINECRAFT_VERSION}.jar;
# We do the above in a single line to reduce the number of layers in our container
# Sets working directory for the CMD instruction (also works for RUN, ENTRYPOINT commands)
# Create mount point, and mark it as holding externally mounted volume
WORKDIR /data
VOLUME /data
# Automatically accept Minecraft EULA
RUN echo eula=true > /data/eula.txt
# Expose the container's network port: 25565 during runtime.
EXPOSE 25565
# Start Minecraft server
CMD java -Xmx${MINECRAFT_MAX_MEMORY} -Xms1024M -jar /minecraft_server_${MINECRAFT_VERSION}.jar