Skip to content

Instantly share code, notes, and snippets.

@amolloy
Created March 19, 2019 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amolloy/095a4799bfc778ed03f4fc160a0c4cb9 to your computer and use it in GitHub Desktop.
Save amolloy/095a4799bfc778ed03f4fc160a0c4cb9 to your computer and use it in GitHub Desktop.
Import an existing minecraft server world into a new docker container
#!/bin/bash
if [ ! -d "$1" ]; then
echo Unknown directory $1, aborting.
exit 1
fi
re='^[0-9]+$'
if ! [[ $2 =~ $re ]]; then
echo Second argument must be the port number. Abording.
exit 2
fi
WORLD=`basename $1`
echo Importing $WORLD from $1.
docker create -e EULA=TRUE -e TYPE=PAPER -e ONLINE_MODE=FALSE -p $2:25565 --name MC-$WORLD itzg/minecraft-server --noconsole
docker cp $1/. MC-$WORLD:/data/
docker start MC-$WORLD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment