3 minutes to set up an Minecraft server with Docker

  • 2020-05-24 06:28:19
  • OfStack

I wrote the 1 in front

As a senior gamer, I rejected Minecraft (my world) for the first time, but after playing it for a while, I couldn't stop. As a sandbox game, Minecraft (hereinafter referred to as MC) has a high degree of freedom. What you want to play is entirely up to you. You can do traditional wilderness survival, monster fighting upgrades, you can build all kinds of buildings, you can become a redstone master, you can automate everything. This is one of the most typical "someone else's game", a god in the game built a 32-bit computer you can believe? Other people's world, oh no, my world so much.

To get back to the point, I built an original Minecraft survival suit out of the netease honeycomb container some time ago. That's a 6 for fun. Think of the majority of small partners or play single machine, can not play happily with good gay friends 1; Or play with someone else's limited clothing, all kinds of uncomfortable. Therefore, I specially arranged 1 tutorial for the benefit of MCers.

2 how to build

As we all know, MC is written by JAVA. Both the client side and the server side are directly an jar package, so the prerequisite is to have an jre. My MC clothing is completely built by hand. Let me briefly explain the steps of manual construction.

1, create an Linux container, ubuntu, debian, centos, see what you like, I use debian

2. Install jre or jdk

3. Install basic tools, tmux, vim, etc

4. Download the server files of Minecraft

5. Run Minecraft server files using tmux

6. Basic server configuration

Why do we use tmux here? Because we are running a game suit, we have to perform some operations under the premise of constantly serving, such as adding op, ban dropping a certain ip, etc., and then let it continue to run in the background. tmux just meets this requirement, of course other tools can also be used, but I am used to using tmux.

You can see that manual operation is still a little bit troublesome. Is there an easier way? The answer is yes. Netease honeycomb is a container cloud platform based on Docker. By taking advantage of the features of Docker, we can create an MC server image through Dockerfile, and then create a container with the image.

Docker Minecraft server

Let me introduce the Dockerfile, because honeycomb has an jdk mirror officially, so use it as the base mirror, and then install some basic tools. Part 2 creates a directory to use as the working directory and downloads the server files to that directory. Part 3 is about creating and setting up the files required for the MC server, more on that later. Part 4 represents the entry point at container startup, using tmux to have the server run in the background while enabling ssh login. The jvm parameter was not specified when you started the server because you were not sure what specifications you were using to create the container.

In step 2, I uploaded the server file to oschina's git library for demonstration purposes. Of course, here you can replace the address of the server file you want to download, if there is already a downloaded file, you can upload it directly to the container.

The names of the files required by the MC server clearly tell you what they do.

The first file is eula.txt, literally, the end user license agreement, which you must agree to (eula=true in the file) in order to start the server properly. When you do not create the file, the server will automatically create eula.txt on the first run and tell you that you must agree to the protocol in order to continue.

Another very important file is server.properties, which contains various parameters related to the server. You can directly go to wiki to see the meaning of each parameter. There is only one parameter related to login, online-mode =true, which means whether online authentication is enabled. What does it mean? When online authentication is started, the server will verify whether the account is legitimate in the account system of Minecraft for each login account. If you want to turn off online authentication when the server starts, add RUN echo online-mode =false in part 3 > server. properties is fine, but when online verification is turned off, any logon account will not be verified. If you log in directly, that is to say, as long as you know someone else's user name, you can log into someone else's account directly.

Other documents, such as ip blacklist banned-ips. json, account blacklist banned-players. json, op list ops. json, etc.

3. Start the MC journey

Use Dockerfile build custom image, and build a good image to create a container, specific methods are not opened here, you can reference the beehive official documentation https: / / c. 163. com/wiki/index php & # 63; title = create custom image and https: / / c. 163. com/wiki/index php & # 63; title= create the container.

Once the container has been created, open the Minecraft client, enter the ip container exnet you just created, and start your Minecraft journey.

A word of caution: as we all know, Minecraft eats a lot of memory, so it is recommended that you use a memory 1G or more.

4 afterword.


Related articles: