---
title: "Run a Minecraft Server With Docker: Setup Guide | ZCS"
description: "A containerized server starts the same way every time, on any machine with Docker installed, with no Java versions to match by hand."
url: "https://www.zcraftstudios.com/blog/docker-minecraft-server-setup"
updated: "2026-10-20T07:16:50.972429+00:00"
source: "ZCraft Studios"
---

> Site index for AI agents: https://www.zcraftstudios.com/llms.txt (full reference: https://www.zcraftstudios.com/llms-full.txt). Every page is available as Markdown by adding `.md` to its URL or sending `Accept: text/markdown`.

1. [Home](https://www.zcraftstudios.com/)
2. [Blog](https://www.zcraftstudios.com/blog)
3. Run a Minecraft Server With Docker: Setup Guide

[ All posts](https://www.zcraftstudios.com/blog)

# Run a Minecraft Server With Docker: Setup Guide

ZCraft StudiosOct 3, 2026Updated Oct 20, 2026

A containerized server starts the same way every time, on any machine with Docker installed, with no Java versions to match by hand.

## In this guide

- [Install Docker](#install-docker)
- [Using an Existing Minecraft Docker Image](#using-an-existing-minecraft-docker-image)
- [Using Docker Compose Instead](#using-docker-compose-instead)
- [Installing Plugins in a Containerized Server](#installing-plugins-in-a-containerized-server)
- [Accessing the Server Console](#accessing-the-server-console)
- [Why Containerize at All](#why-containerize-at-all)
- [Understand persistent storage before deploying](#understand-persistent-storage-before-deploying)
- [Keep the service definition separate from persistent data](#keep-the-service-definition-separate-from-persistent-data)
- [Official documentation and links](#official-documentation-and-links)
- [Preserve data across container replacement](#preserve-data-across-container-replacement)

## Running a Minecraft Server With Docker

_The same server, the same Java version, the same config, whether on a laptop or a VPS, without manually setting up the environment each time._

Running a Minecraft server in Docker packages the server, its Java runtime, and its dependencies into a container that behaves identically regardless of the host machine. That's useful for consistency across development and production, or just avoiding a manual Java install.

## Install Docker

On a Linux host:

```
curl -fsSL https://get.docker.com | sh
sudo usermod -aG docker $USER
```

Log out and back in for the group change to take effect.

## Using an Existing Minecraft Docker Image

The `itzg/minecraft-server` image is a widely-used, well-maintained option that handles the EULA, server type selection, and most common configuration through environment variables:

```
docker run -d \
  -p 25565:25565 \
  -e EULA=TRUE \
  -e TYPE=PAPER \
  -e MEMORY=4G \
  -v /home/mc/data:/data \
  --name mc-server \
  itzg/minecraft-server
```

`-v /home/mc/data:/data` maps the container's world/plugin data to a real folder on the host, so it persists even if the container is removed and recreated.

## Using Docker Compose Instead

For easier long-term management, a `docker-compose.yml` is usually cleaner than a long `docker run` command:

```
version: "3.8"
services:
  mc:
    image: itzg/minecraft-server
    ports:
      - "25565:25565"
    environment:
      EULA: "TRUE"
      TYPE: "PAPER"
      MEMORY: "4G"
    volumes:
      - ./data:/data
    restart: unless-stopped
```

Then start it with:

```
docker compose up -d
```

`restart: unless-stopped` automatically restarts the container if it crashes or the host reboots.

## Installing Plugins in a Containerized Server

Plugins go in the mapped volume's `plugins/` folder on the host (`/home/mc/data/plugins` in the example above). They're accessible directly from the host filesystem, the same as a non-containerized server, since the volume mount makes them visible on both sides.

## Accessing the Server Console

```
docker attach mc-server
```

attaches to the running container's console. `Ctrl+P` then `Ctrl+Q` detaches without stopping the server (regular `Ctrl+C` would stop it).

Or, for sending a single command without a full attach:

```
docker exec mc-server rcon-cli say Hello from the host
```

(requires RCON enabled, which the `itzg/minecraft-server` image supports via additional environment variables).

## Why Containerize at All

- Consistent Java version and environment regardless of host OS
- Easy to tear down and recreate without losing world data (as long as the volume is preserved)
- Simple to run multiple isolated servers on one host, each in its own container with its own port mapping

## Understand persistent storage before deploying

Containers make it easier to recreate the server process, but player worlds and plugin configurations must survive container replacement. Mount a persistent host directory or managed volume for the server data, verify the correct file permissions and include that storage in your backup process.

### Container acceptance test

1. Start the server with an explicitly selected image version and required environment settings.
2. Join and create a small change in the test world.
3. Stop the container cleanly and replace it using the same persisted data.
4. Confirm that the world, inventory and plugin configuration remain available.
5. Confirm logs are visible and restart policies do not hide repeated startup failures.

Avoid publishing management interfaces or container-control sockets to the internet. A working container launch is not proof that your world data is safely stored.

## Keep the service definition separate from persistent data

Record your container image tag, environment settings, volumes and port mappings in a maintained service definition. Keep credentials outside public examples. Check which paths contain the world, plugin files and configuration, then verify those paths persist across container recreation. A file that survives an ordinary restart may still disappear when the container is replaced. Test that distinction on a copy before relying on the arrangement for production recovery.

Plan an image update as a server update. Read the relevant changes, keep a working prior definition and confirm whether upgraded world data can safely return to the older software. Test startup limits and graceful shutdown before enabling automatic restarts. If startup repeatedly fails, inspect the logs and stop the loop rather than hiding it with another supervisor. Back up external database records separately if they are not part of the game's persistent volume.

### Troubleshooting paths

- Files vanish after recreation: inspect the actual volume mapping.
- Startup loops: preserve logs and review memory and configuration errors.
- Restore looks incomplete: check external data and the saved service definition.

## Official documentation and links

- [Official project repository](https://github.com/itzg/docker-minecraft-server)
- [A Minecraft Server Backup Strategy](https://www.zcraftstudios.com/blog/minecraft-server-backup-strategy)

## Preserve data across container replacement

The container is disposable; worlds and configuration must live on a persistent volume or bind mount that survives recreation. Verify persistence by stopping the server, creating a test change, and recreating the container using the same volume mapping. Keep backups outside the same storage failure domain.

Pin a compatible server image or version configuration and review changes before upgrading. An automatically pulled image can otherwise change Java or server behavior unexpectedly.

## Continue reading

- [How to Run a Minecraft UHC Event: Fair Starts](https://www.zcraftstudios.com/blog/minecraft-server-uhc-event-planning)

[ Previous guide Setting Up ViaVersion for Cross-Version Compatibility](https://www.zcraftstudios.com/blog/viaversion-cross-version-setup)[ Next guide Setting Up AuthMe for Offline-Mode Authentication](https://www.zcraftstudios.com/blog/authme-offline-mode-authentication-setup)
