Marvel Heroes Docker Container
This Docker container runs a Marvel Heroes server: MHServerEmu 1.0.3 for Marvel Heroes Omega 1.52.0.1700, on .NET 10. It is built on the base image. MHServerEmu is baked into the image. nginx takes the place of the Apache server MHServerEmu ships for Windows. You supply two data files from the game client, Calligraphy.sip and mu_cdata.sip.
Quick Start
services:
marvelheroes:
image: lancommander/marvelheroes:latest
container_name: marvelheroes
ports:
- 4306:4306/tcp
- 80:80/tcp
- 443:443/tcp
volumes:
- "/servers/Marvel Heroes/Default:/config"
environment:
MH_PUBLIC_ADDRESS: "192.168.1.50"
MH_SERVER_NAME: "Marvel Heroes LAN"
user: root
cap_add:
- SYS_ADMIN
security_opt:
- apparmor:unconfined
stop_grace_period: 30s
restart: unless-stopped
Copy Calligraphy.sip and mu_cdata.sip from a 1.52.0.1700 client's Data/Game/ into config/ClientData/ first.
How It Starts
PostInitialization/20-InstallMHServerEmu.ps1copies MHServerEmu from/opt/mhserveremuin the image intoServer/whenServer/.mhserveremu-versionis missing or names another version. Before that it unmounts the overlay. When it replaces another version, it renames that version'sConfig.ini,htdocs/SiteConfig.xmlandhtdocs/news/index.htmlinOverlay/to*.bak-<old version>and emptiesServer/. Then it remounts. It then copiesCalligraphy.sipandmu_cdata.sipfromMH_CLIENT_DATA_DIRintoData/Game/(throughMerged/, so intoOverlay/) when they're missing or differ in size or date.PostInitialization/30-ConfigureMHServerEmu.ps1works out the public address (MH_PUBLIC_ADDRESS, or the container's IPv4 address) and writesConfigOverride.inifrom theMH_*andMHSE__*variables. It setsAuthServerAddressandLoadScreenTipsURLinhtdocs/SiteConfig.xmland the patch notes link inhtdocs/news/index.htmlto that address.PostInitialization/40-StartWebServer.ps1writes/etc/nginx/nginx.confand starts nginx. nginx servesMerged/htdocs/on 80, and passes/AuthServer,/Dashboard,/MTXStore,/AccountManagement,/ServerStatus,/RegionReportand/Metricson to MHServerEmu's web front end (127.0.0.1:MH_WEB_PORT) on 80 and 443.PostInitialization/50-ConsoleAndStopSignal.ps1creates/run/mhserveremu/and registers a SIGTERM/SIGINT handler in the entrypoint process (see Stopping).START_EXE(/usr/local/bin/mhserveremu-server) checks for the.sipfiles and runsdotnet MHServerEmu.dll <START_ARGS>inMerged/. The server's console input is the FIFO/run/mhserveremu/console, plus the container's stdin when one is attached.
A successful start ends with:
[...] [ Info] [PakFileSystem] Loaded 7928 entries from mu_cdata.sip
[...] [ Info] [PakFileSystem] Loaded 94788 entries from Calligraphy.sip
...
[...] [ Info] [GameDatabase] Finished initializing game database in 6388 ms
...
[...] [ Info] [FrontendServer] FrontendServer is listening on 0.0.0.0:4306...
[...] [ Info] [WebService] WebFrontend is listening on http://127.0.0.1:8080/...
[...] [ Info] [ServerApp] Type '!commands' for a list of available commands
Startup takes about 10 seconds and the server uses about 650 MB of memory with nobody on.
Configuration Options
Ports
- 4306/tcp: Game frontend (
MH_FRONTEND_PORT). The client connects to[Frontend] PublicAddresson this port after logging in. - 80/tcp:
SiteConfig.xml(the first thing the client loads), the store, news and loading-tips pages, the account dashboard (/Dashboard/). - 443/tcp: HTTPS login (
/AuthServer/Login/IndexPB). The client takes the host fromSiteConfig.xml'sAuthServerAddressand the port fromAuthServerPort.
MHServerEmu's own web front end (8080) only listens on 127.0.0.1 and isn't exposed.
Public address
The client reads the server's address from three places, all set from the public address on every start:
-siteconfigurl=<address>/SiteConfig.xmlon the client's command line (yours to set)AuthServerAddressinSiteConfig.xml(login)[Frontend] PublicAddressinConfigOverride.ini(game connection, sent to the client at login)
With MH_PUBLIC_ADDRESS empty, the container's first IPv4 address is used. That is right on a macvlan network where the container has its own LAN address. Behind Docker's port publishing (bridge network), set MH_PUBLIC_ADDRESS to the host's LAN address or name, or clients get an address they can't reach.
Environment Variables
See the README for the full table.
Config.ini and ConfigOverride.ini
MHServerEmu reads Config.ini, then ConfigOverride.ini over it. The hook rewrites ConfigOverride.ini on every start: the frontend, web front end, news and store URLs, the MH_* settings, then every MHSE__<Section>__<Key> variable, e.g. MHSE__CustomGameOptions__DisableInstancedLoot=true or MHSE__GameData__LoadAllPrototypes=true. For anything else, edit Overlay/Config.ini (copy it from Server/); every setting is documented in the file. Worth knowing:
[CustomGameOptions]:DisableInstancedLoot,DisableAccountBinding,DisableCharacterBinding,AllowSameGroupTalents,ESCooldownOverrideMinutes,EnableUltimatePrestige[GameOptions]: feature switches sent to the client (Infinity vs Omega, difficulty slider, tutorial)[GameData] LoadAllPrototypes=true: a slower start, but no hitches the first time a region loads[GameInstance] NumWorkerThreads: game instance threads, up to the CPU countData/Game/LiveTuning/: XP, loot and event multipliers
Accounts and admins
Players create accounts on the dashboard at http://<server>/Dashboard/, or you create them in the server console with !account create <email> <playerName> <password>. New accounts are user level 0. Make an admin with !account userlevel <email> 2 (1 = moderator). Admins can run every ! command in the in-game chat as well. !commands lists them.
Run console commands from the host with:
docker exec marvelheroes mhserveremu-command '!account userlevel me@example.com 2'
The output is in the container's log. With stdin_open: true, commands can also be typed into the container's stdin (e.g. docker attach, or a LANCommander console).
Stopping
MHServerEmu saves a player when they log out or change regions, and every MH_AUTOSAVE_MINUTES (5 by default, MHServerEmu's own default is 15). On !server shutdown it saves everyone, but it saves nothing when it's killed. docker stop only signals PID 1, the base image's PowerShell entrypoint, so 50-ConsoleAndStopSignal.ps1 registers a handler there that sends !server shutdown instead of exiting. The launcher closes the console once the server logs All services shut down, and the server exits with code 0, usually within a few seconds. Give the container a stop_grace_period of 30s or so, so a busy server isn't killed mid-save. A second signal isn't held back.
Web files (htdocs)
htdocs/ is the web root: SiteConfig.xml, LiveLoadingTips.xml, news/, store/ and bundles/ (store bundle pages and images). Edit them in Overlay/htdocs/. The hook only changes AuthServerAddress and LoadScreenTipsURL in SiteConfig.xml and the patch notes link in news/index.html. nginx is case-sensitive where Windows' Apache wasn't, so /liveloadingtips.xml and /siteconfig.xml are mapped to the real names. The released SiteConfig.xml asks for the lowercase one.
Logs
The server logs to the console (docker logs). MH_LOG_LEVEL sets the console's level. The default of 2 (info) hides the trace lines MHServerEmu prints at startup and on every garbage collection. For a log file, set MHSE__Logging__EnableFile=true. It writes Logs/MHServerEmu_<date>.log in Overlay/, a new file every start. Crash reports go to Overlay/CrashReports/. nginx logs to /var/log/nginx/ in the container.
Hooks
| Hook | When |
|---|---|
PreInstallMHServerEmu / PostInstallMHServerEmu | Around the MHServerEmu install and client data copy |
Put .ps1 scripts in config/Scripts/Hooks/<HookName>/.
Troubleshooting
Data/Game/Calligraphy.sip not foundand the container stops: copyCalligraphy.sipandmu_cdata.sipfrom the client'sData/Game/intoconfig/ClientData/(orMH_CLIENT_DATA_DIR) and restart.- The client can't connect / hangs at "Connecting": check the client loads
http://<address>/SiteConfig.xmland that itsAuthServerAddressis an address the client can reach. Check the log'sPublic address:line; if it's a Docker bridge address (172.17.x.x), setMH_PUBLIC_ADDRESS. - Login works but the game doesn't load: 4306/tcp isn't reachable at
[Frontend] PublicAddress. - "Client version mismatch" in the log: the client isn't 1.52.0.1700. Use that version, or set
MHSE__PlayerManager__AllowClientVersionMismatch=trueat your own risk. HTTP_FILESERVER_ENABLED is setwarning: the base image's file server also wants port 80. Leave it off; this image's nginx already serves the web files.*.bak-<version>files inOverlay/: the image brought a new MHServerEmu version and moved your edited copies of the old version's files aside. Reapply your changes to the new files, then delete the backups.- Progress lost after a restart: the container was killed before the server could save (no
!server shutdownin the log). Usedocker stopwith enoughstop_grace_period, or lowerMH_AUTOSAVE_MINUTES. Account.db.oldappeared: MHServerEmu 1.x can't read 0.x account databases. It renames them and starts a new one.