cwlf/mc-server
This docker image provides a Minecraft Server that will automatically download the latest stable version at startup. You can also run/upgrade to any specific version or the latest snapshot. See the Versions section below for more information.
Full docs available in Github
To simply use the latest stable version, run
docker run -d -p 25565:25565 --name mc itzg/minecraft-server
where the standard server port, 25565, will be exposed on your host machine.
If you want to serve up multiple Minecraft servers or just use an alternate port, change the host-side port mapping such as
docker run -p 25566:25565 ...
will serve your Minecraft server on your host's port 25566 since the -p
syntax is
host-port
:container-port
.
Speaking of multiple servers, it's handy to give your containers explicit names using --name
, such as
docker run -d -p 25565:25565 --name mc itzg/minecraft-server
With that you can easily view the logs, stop, or re-start the container:
docker logs -f mc
( Ctrl-C to exit logs action )
docker stop mc
docker start mc
For Minecraft clients running on consoles, mobile, or native Windows, you'll need to use this image instead:
RCON is enabled by default, so you can exec
into the container to
access the Minecraft server console:
docker exec -i mc rcon-cli
Note: The -i
is required for interactive use of rcon-cli.
To run a simple, one-shot command, such as stopping a Minecraft server, pass the command as
arguments to rcon-cli
, such as:
docker exec mc rcon-cli stop
The -i
is not needed in this case.
In order to attach and interact with the Minecraft server, add -it
when starting the container, such as
docker run -d -it -p 25565:25565 --name mc itzg/minecraft-server
With that you can attach and interact at any time using
docker attach mc
and then Control-p Control-q to detach.
For remote access, configure your Docker daemon to use a tcp
socket (such as -H tcp://0.0.0.0:2375
)
and attach from another machine:
docker -H $HOST:2375 attach mc
Unless you're on a home/private LAN, you should enable TLS access.
Mojang now requires accepting the Minecraft EULA. To accept add
-e EULA=TRUE
such as
docker run -d -it -e EULA=TRUE -p 25565:25565 --name mc itzg/minecraft-server
In order to readily access the Minecraft data, use the -v
argument
to map a directory on your host machine to the container's /data
directory, such as:
docker run -d -v /path/on/host:/data ...
When attached in this way you can stop the server, edit the configuration under your attached /path/on/host
and start the server again with docker start CONTAINERID
to pick up the new configuration.
To use a different Minecraft version, pass the VERSION
environment variable, which can have the value
For example, to use the latest snapshot:
docker run -d -e VERSION=SNAPSHOT ...
or a specific version:
docker run -d -e VERSION=1.7.9 ...
When using "LATEST" or "SNAPSHOT" an upgrade can be performed by simply restarting the container.
During the next startup, if a newer version is available from the respective release channel, then
the new server jar file is downloaded and used. NOTE: over time you might see older versions of
the server jar remain in the /data
directory. It is safe to remove those.
To use a different version of Java, please use a docker tag to run your Minecraft server.
Tag name | Description | Linux |
---|---|---|
latest | Default. Uses Java version 8 update 212 | Alpine Linux |
adopt13 | Uses Java version 13 latest update | Alpine Linux |
adopt11 | Uses Java version 11 latest update | Alpine Linux |
openj9 | Uses Eclipse OpenJ9 JVM | Alpine Linux |
openj9-nightly | Uses Eclipse OpenJ9 JVM testing builds | Alpine Linux |
multiarch | Uses Java version 8 latest update | Debian Linux |
For example, to use a Java version 13:
docker run --name mc itzg/minecraft-server:adopt13
Keep in mind that some versions of Minecraft server can't work on the newest versions of Java. Also, FORGE doesn't support openj9 JVM implementation.
This image contains mc-monitor and uses
its status
command to continually check on the container's. That can be observed
from the STATUS
column of docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
b418af073764 mc "/start" 43 seconds ago Up 41 seconds (healthy) 0.0.0.0:25565->25565/tcp, 25575/tcp mc
You can also query the container's health in a script friendly way:
> docker container inspect -f "{{.State.Health.Status}}" mc
healthy
The examples directory also provides examples of deploying the itzg/minecraft-server Docker image.
Enable Forge server mode by adding a -e TYPE=FORGE
to your command-line.
By default the container will run the RECOMMENDED
version of Forge server
but you can also choose to run a specific version with -e FORGEVERSION=10.13.4.1448
.
$ docker run -d -v /path/on/host:/data -e VERSION=1.7.10 \
-e TYPE=FORGE -e FORGEVERSION=10.13.4.1448 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
To use a pre-downloaded Forge installer, place it in the attached /data
directory and
specify the name of the installer file with FORGE_INSTALLER
, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FORGE_INSTALLER=forge-1.11.2-13.20.0.2228-installer.jar ...
To download a Forge installer from a custom location, such as your own file repository, specify
the URL with FORGE_INSTALLER_URL
, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FORGE_INSTALLER_URL=http://HOST/forge-1.11.2-13.20.0.2228-installer.jar ...
In both of the cases above, there is no need for the VERSION
or FORGEVERSION
variables.
In order to add mods, you have two options.
This is the easiest way if you are using a persistent /data
mount.
To do this, you will need to attach the container's /data
directory
(see "Attaching data directory to host filesystem”).
Then, you can add mods to the /path/on/host/mods
folder you chose. From the example above,
the /path/on/host
folder contents look like:
/path/on/host
├── mods
│ └── ... INSTALL MODS HERE ...
├── config
│ └── ... CONFIGURE MODS HERE ...
├── ops.json
├── server.properties
├── whitelist.json
└── ...
If you add mods while the container is running, you'll need to restart it to pick those up:
docker stop mc
docker start mc
This is the easiest way if you are using an ephemeral /data
filesystem,
or downloading a world with the WORLD
option.
There are two additional volumes that can be mounted; /mods
and /config
.
Any files in either of these filesystems will be copied over to the main
/data
filesystem before starting Minecraft.
This works well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive.
Sometimes you have mods or plugins that require configuration information that is only available at runtime. For example if you need to configure a plugin to connect to a database, you don't want to include this information in your Git repository or Docker image. Or maybe you have some runtime information like the server name that needs to be set in your config files after the container starts.
For those cases there is the option to replace defined variables inside your configs with environment variables defined at container runtime.
If you set the enviroment variable REPLACE_ENV_VARIABLES
to TRUE
the startup script
will go thru all files inside your /data
volume and replace variables that match your
defined environment variables. Variables that you want to replace need to be wrapped
inside ${YOUR_VARIABLE}
curly brackets and prefixed with a dollar sign. This is the regular
syntax for enviromment variables inside strings or config files.
Optionally you can also define a prefix to only match predefined enviroment variables.
ENV_VARIABLE_PREFIX="CFG_"
<-- this is the default prefix
There are some limitations to what characters you can use.
Type | Allowed Characters |
---|---|
Name | 0-9a-zA-Z_- |
Value | 0-9a-zA-Z_-:/=?.+ |
Variables will be replaced in files with the following extensions:
.yml
, .yaml
, .txt
, .cfg
, .conf
, .properties
.
Here is a full example where we want to replace values inside a database.yml
.
---
database:
host: ${CFG_DB_HOST}
name: ${CFG_DB_NAME}
password: ${CFG_DB_PASSWORD}
This is how your docker-compose.yml
file could look like:
version: "3"
# Other docker-compose examples in /examples
services:
minecraft:
image: itzg/minecraft-server
ports:
- "25565:25565"
volumes:
- "mc:/data"
environment:
EULA: "TRUE"
ENABLE_RCON: "true"
RCON_PASSWORD: "testing"
RCON_PORT: 28016
# enable env variable replacement
REPLACE_ENV_VARIABLES: "TRUE"
# define an optional prefix for your env variables you want to replace
ENV_VARIABLE_PREFIX: "CFG_"
# and here are the actual variables
CFG_DB_HOST: "http://localhost:3306"
CFG_DB_NAME: "minecraft"
CFG_DB_PASSWORD: "ug23u3bg39o-ogADSs"
restart: always
rcon:
image: itzg/rcon
ports:
- "4326:4326"
- "4327:4327"
volumes:
- "rcon:/opt/rcon-web-admin/db"
volumes:
mc:
rcon:
Enable Bukkit/Spigot server mode by adding a -e TYPE=BUKKIT -e VERSION=1.8
or -e TYPE=SPIGOT -e VERSION=1.8
to your command-line.
docker run -d -v /path/on/host:/data \
-e TYPE=SPIGOT -e VERSION=1.8 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
If you are hosting your own copy of Bukkit/Spigot you can override the download URLs with:
You can build spigot from source by adding -e BUILD_FROM_SOURCE=true
NOTE: to avoid pegging the CPU when running Spigot, you will need to
pass --noconsole
at the very end of the command line and not use -it
. For example,
docker run -d -v /path/on/host:/data \
-e TYPE=SPIGOT -e VERSION=1.8 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server --noconsole
You can install Bukkit plugins in two ways...
This is the easiest way if you are using a persistent /data
mount.
To do this, you will need to attach the container's /data
directory
(see "Attaching data directory to host filesystem”).
Then, you can add plugins to the /path/on/host/plugins
folder you chose. From the example above,
the /path/on/host
folder contents look like:
/path/on/host
├── plugins
│ └── ... INSTALL PLUGINS HERE ...
├── ops.json
├── server.properties
├── whitelist.json
└── ...
If you add plugins while the container is running, you'll need to restart it to pick those up:
docker stop mc
docker start mc
This is the easiest way if you are using an ephemeral /data
filesystem,
or downloading a world with the WORLD
option.
There is one additional volume that can be mounted; /plugins
.
Any files in this filesystem will be copied over to the main
/data/plugins
filesystem before starting Minecraft.
This works well if you want to have a common set of plugins in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive.
Enable PaperSpigot server mode by adding a -e TYPE=PAPER -e VERSION=1.9.4
to your command-line.
docker run -d -v /path/on/host:/data \
-e TYPE=PAPER -e VERSION=1.9.4 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
NOTE: to avoid pegging the CPU when running PaperSpigot, you will need to
pass --noconsole
at the very end of the command line and not use -it
. For example,
docker run -d -v /path/on/host:/data \
-e TYPE=PAPER -e VERSION=1.9.4 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server --noconsole
If you are hosting your own copy of PaperSpigot you can override the download URL with:
You can install Bukkit plugins in two ways...
An example compose file is provided at examples/docker-compose-paper.yml.
This is the easiest way if you are using a persistent /data
mount.
To do this, you will need to attach the container's /data
directory
(see "Attaching data directory to host filesystem”).
Then, you can add plugins to the /path/on/host/plugins
folder you chose. From the example above,
the /path/on/host
folder contents look like:
/path/on/host
├── plugins
│ └── ... INSTALL PLUGINS HERE ...
├── ops.json
├── server.properties
├── whitelist.json
└── ...
If you add plugins while the container is running, you'll need to restart it to pick those up:
docker stop mc
docker start mc
This is the easiest way if you are using an ephemeral /data
filesystem,
or downloading a world with the WORLD
option.
There is one additional volume that can be mounted; /plugins
.
Any files in this filesystem will be copied over to the main
/data/plugins
filesystem before starting Minecraft.
This works well if you want to have a common set of plugins in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive.
Enable this server mode by adding a -e TYPE=FTB
or -e TYPE=CURSEFORGE
to your command-line,
but note the following additional steps needed...
You need to specify a modpack to run, using the FTB_SERVER_MOD
or CF_SERVER_MOD
environment
variable. An FTB/CurseForge server modpack is available together with its respective
client modpack on https://www.feed-the-beast.com under "Additional Files." Similar you can
locate the modpacks for CurseForge at https://www.curseforge.com/minecraft/modpacks .
Now you can add a -e FTB_SERVER_MOD=name_of_modpack.zip
to your command-line.
docker run -d -v /path/on/host:/data -e TYPE=FTB \
-e FTB_SERVER_MOD=FTBPresentsSkyfactory3Server_3.0.6.zip \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
If you don't want to keep the pre-download modpacks separate from your data directory,
then you can attach another volume at a path of your choosing and reference that.
The following example uses /modpacks
as the container path as the pre-download area:
docker run -d -v /path/on/host:/data -v /path/to/modpacks:/modpacks \
-e TYPE=FTB \
-e FTB_SERVER_MOD=/modpacks/FTBPresentsSkyfactory3Server_3.0.6.zip \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
If your server's modpack fails to load with an error like this:
unable to launch forgemodloader
then you apply a workaround by adding this to the run invocation:
-e FTB_LEGACYJAVAFIXER=true
If you use something like CurseForge, you may end up creating/using modpacks that do not
contain server mod jars. Instead, the CurseForge setup has manifest.json
files, which
will show up under /data/FeedTheBeast/manifest.json
.
To use these packs you will need to:
MANIFEST=/data/FeedTheBeast/manifest
/data/FeedTheBeast
An example of the latter would be to use https://github.com/AllTheMods/Server-Scripts
There, you'll find that all you have to do is put ServerStart.sh
and settings.cfg
into
/data/FeedTheBeast
, taking care to update settings.cfg
to specify your desired version
of minecraft and forge. You can do this in the cli with something like:
$ wget https://raw.githubusercontent.com/AllTheMods/Server-Scripts/master/ServerStart.sh
$ wget https://raw.githubusercontent.com/AllTheMods/Server-Scripts/master/settings.cfg
$ vim settings.cfg #update the forge version to the one you want. Your manifest.json will have it
$ chmod +x ServerStart.sh
$ docker run -itd --name derpcraft \
-e MANIFEST=/data/FeedTheBeast/manifest.json \
-v $PWD/ServerStart.sh:/data/FeedTheBeast/ServerStart.sh \
-v $PWD/settings.cfg:/data/FeedTheBeast/settings.cfg \
-e VERSION=1.12.2\
-e TYPE=CURSEFORGE\
-e CF_SERVER_MOD=https://minecraft.curseforge.com/projects/your_amazing_modpack/files/2670435/download\
-p 25565:25565\
-e EULA=TRUE\
--restart=always\
itzg/minecraft-server
Note the CF_SERVER_MOD
env var should match the server version of the modpack you are targeting.
Enable SpongeVanilla server mode by adding a -e TYPE=SPONGEVANILLA
to your command-line.
By default the container will run the latest STABLE
version.
If you want to run a specific version, you can add -e SPONGEVERSION=1.11.2-6.1.0-BETA-19
to your command-line.
docker run -d -v /path/on/host:/data -e TYPE=SPONGEVANILLA \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
You can also choose to use the EXPERIMENTAL
branch.
Just change it with SPONGEBRANCH
, such as:
$ docker run -d -v /path/on/host:/data ... \
-e TYPE=SPONGEVANILLA -e SPONGEBRANCH=EXPERIMENTAL ...
Enable Fabric server mode by adding a -e TYPE=FABRIC
to your command-line.
By default the container will run the latest version of Fabric server
but you can also choose to run a specific version with -e FABRICVERSION=0.5.0.32
.
$ docker run -d -v /path/on/host:/data -e VERSION=1.14.3 \
-e TYPE=FABRIC -e FABRICVERSION=0.5.0.32 \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
To use a pre-downloaded Fabric installer, place it in the attached /data
directory and
specify the name of the installer file with FABRIC_INSTALLER
, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FABRIC_INSTALLER=fabric-installer-0.5.0.32.jar ...
To download a Fabric installer from a custom location, such as your own file repository, specify
the URL with FABRIC_INSTALLER_URL
, such as:
$ docker run -d -v /path/on/host:/data ... \
-e FORGE_INSTALLER_URL=http://HOST/fabric-installer-0.5.0.32.jar ...
In both of the cases above, there is no need for the VERSION
or FABRICVERSION
variables.
In order to add mods, you have two options.
This is the easiest way if you are using a persistent /data
mount.
To do this, you will need to attach the container's /data
directory
(see "Attaching data directory to host filesystem”).
Then, you can add mods to the /path/on/host/mods
folder you chose. From the example above,
the /path/on/host
folder contents look like:
/path/on/host
├── mods
│ └── ... INSTALL MODS HERE ...
├── config
│ └── ... CONFIGURE MODS HERE ...
├── ops.json
├── server.properties
├── whitelist.json
└── ...
If you add mods while the container is running, you'll need to restart it to pick those up:
docker stop mc
docker start mc
This is the easiest way if you are using an ephemeral /data
filesystem,
or downloading a world with the WORLD
option.
There are two additional volumes that can be mounted; /mods
and /config
.
Any files in either of these filesystems will be copied over to the main
/data
filesystem before starting Minecraft.
This works well if you want to have a common set of modules in a separate location, but still have multiple worlds with different server requirements in either persistent volumes or a downloadable archive.
If you would like to run a custom server JAR, set -e TYPE=CUSTOM
and pass the custom server
JAR via CUSTOM_SERVER
. It can either be a URL or a container path to an existing JAR file.
If it is a URL, it will only be downloaded into the /data
directory if it wasn't already. As
such, if you need to upgrade or re-download the JAR, then you will need to stop the container,
remove the file from the container's /data
directory, and start again.
For VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types, set
$FORCE_REDOWNLOAD
to some value (e.g. 'true) to force a re-download of the server file for
the particular server type. by adding a -e FORCE_REDOWNLOAD=true
to your command-line.
For example, with PaperSpigot, it would look something like this:
docker run -d -v /path/on/host:/data \
-e TYPE=PAPER -e VERSION=1.14.1 -e FORCE_REDOWNLOAD=true \
-p 25565:25565 -e EULA=TRUE --name mc itzg/minecraft-server
Rather than type the server options below, the port mappings above, etc
every time you want to create new Minecraft server, you can now use
Docker Compose. Start with a
docker-compose.yml
file like the following:
minecraft-server:
ports:
- "25565:25565"
environment:
EULA: "TRUE"
image: itzg/minecraft-server
container_name: mc
tty: true
stdin_open: true
restart: always
and in the same directory as that file run
docker-compose up -d
Now, go play...or adjust the environment
section to configure
this server instance.
By default the server configuration will be created and set based on the following
environment variables, but only the first time the server is started. If the
server.properties
file already exists, the values in them will not be changed.
If you would like to override the server configuration each time the container starts up, you can set the OVERRIDE_SERVER_PROPERTIES environment variable like:
docker run -d -e OVERRIDE_SERVER_PROPERTIES=true ...
This will reset any manual configuration of the server.properties
file, so if
you want to make any persistent configuration changes you will need to make sure
you have properly set the proper environment variables in your docker run command (described below).
The server name (e.g. for bungeecord) can be set like:
docker run -d -e SERVER_NAME=MyServer ...
The server port can be set like:
docker run
docker pull cwlf/mc-server