.. _run_server: Run a server ============ ``mciwb start`` runs a Minecraft Java Edition server on this machine, in a `Podman `_ container. Start and stop -------------- :: $ mciwb start $ mciwb stop ``mciwb start`` makes a server called ``mciwb-server`` that keeps its world in ``~/mciwb-server``: a normal world with the seed 0, in creative mode. It listens for RCON on port 20100, and for Minecraft clients on the next port, 20101. ``mciwb stop`` stops the server and removes its container. The world stays in its folder, and the next ``mciwb start`` opens it again. Useful options (``mciwb start --help`` and :doc:`/reference/cli` list them all): ``--world-type flat`` A flat world, with the ground at y = -61. It only affects a new world, so use a new ``--folder`` as well. ``--folder``, ``--server-name``, ``--port`` For a second server beside the first: give each its own folder, name and RCON port, and give the same ``--port`` to the other mciwb commands. ``--password-file`` Choose the RCON password, see `rcon_password`. These options are only used when the server's container is made. If the container is already there, ``mciwb start`` starts it as it was made and warns about the options that differ: run ``mciwb stop`` first (with its ``--server-name``, if you gave it one). .. _podman: Set up Podman ------------- mciwb talks to Podman through its service socket, so as well as installing Podman you switch that service on, once. Linux Install Podman with your package manager (``apt`` here, see `Podman's instructions `_ for others), then switch on its service for your user. It starts again each time you log in:: $ sudo apt install podman $ systemctl --user enable --now podman.socket To have the Minecraft server start again after a reboot, also run ``systemctl --user enable podman-restart.service``. Windows Use WSL2 with Ubuntu: ``wsl --install -d Ubuntu`` in PowerShell, which installs the current Ubuntu (``wsl --list --online`` shows the others on offer). Then follow the Linux steps in the Ubuntu terminal, and install and run mciwb there too. If ``systemctl`` says that systemd is not running, add these lines to ``/etc/wsl.conf`` in Ubuntu, then run ``wsl --shutdown`` in PowerShell and open Ubuntu again:: [boot] systemd=true macOS Install `Podman Desktop `_ and start a Podman machine with it, or use Homebrew:: $ brew install podman $ podman machine init $ podman machine start Then tell mciwb where the machine's socket is. Put this line in ``~/.zshrc``:: export CONTAINER_HOST=unix://$(podman machine inspect --format '{{.ConnectionInfo.PodmanSocket.Path}}') mciwb looks for the socket in ``CONTAINER_HOST``, then ``$XDG_RUNTIME_DIR/podman/podman.sock``, then ``/run/podman/podman.sock``. After a reboot -------------- On Linux and WSL2 the Podman service starts when you log in. On macOS, start the Podman machine (``podman machine start``). Then run ``mciwb start``, unless ``podman-restart.service`` has started the server already. Run mciwb in a container ------------------------ mciwb itself is also published as a container image, with the ``mciwb`` command as its entrypoint. It can run scripts against a server on the same machine. Use host networking, so that ``localhost:20100`` reaches the server:: $ podman run --rm --network host -v $(pwd):/work ghcr.io/gilesknap/mciwb:latest run /work/build.py The image cannot run ``mciwb start``, ``stop``, ``backup`` or ``restore``, which control Podman and the server's files. Its ``mciwb render`` cannot see the world's files either, so it reads blocks over RCON, which is slow. Install mciwb on the host for those (see :doc:`../tutorials/01-first-build`). Use another server ------------------ ``mciwb run`` and ``mciwb shell`` work with any Java Edition server that has RCON switched on (``enable-rcon``, ``rcon.port`` and ``rcon.password`` in its ``server.properties``):: $ mciwb run build.py --server my.server.org --port 25575 --password-file ~/.mciwb-password ``Item`` has the blocks of Minecraft 26.3, so a server on another release may reject some of them. See :doc:`../explanations/server-config` for what else changes with a server that mciwb did not start.