Preface
Continue to build a nostalgic simulator (see article:Use docker to deploy web-side nostalgic game emulator based on emulatorjs) After that, I continued to look for similar interesting projects built with Docker to enrich the "Game World" section of my blog. After some searching, I found this project on GitHub: rwv/chinese-dos-games. Someone made it into a Docker image: oldiy/dosgame-web-docker. This time I used it to build Docker.
Deploy dosgame
Because the docker has 42 games built in, which are stored in the /app/static/games directory in the container, you cannot directly use the -v parameter to mount the host folder to the /app/static/games directory when you start it for the first time, because the host folder is empty and these games will be gone if you mount them directly (it is not impossible, but you need to add each game manually). So the correct procedure is to deploy without the -v parameter first, and after docker runs successfully, copy the contents of /app/static/games to the host's mount folder, delete docker, and then deploy the container with the -v parameter, so that you can add games directly in the host's mount directory in the future.
1. Deploy directly without adding the -v parameter
docker run -d --name dosgame -p 262:262 oldiy/dosgame-web-docker:latest
2. Copy the /app/static/games folder in the container to /docker/dosgame/games on the host machine
mkdir -p /docker/dosgame docker cp dosgame:/app/static/games /docker/dosgame
3. Delete the created container
docker stop dosgame docker rm dosgame
4. Re-deploy with the -v parameter
docker run --name dosgame -d --restart=always \ -p 262:262 \ # Modify the mapping port according to your actual situation -v /docker/dosgame/games:/app/static/games \ # Mount the corresponding folder of the host machine to the container oldiy/dosgame-web-docker:latest
Access the game
usehttp://Host IP:262
Access the game:
The default games provided are as follows:
The interface of Chinese Paladin:
Some games do not support mouse, such as Chinese Paladin; some support, such as Monopoly 3, these are waiting for you to explore. General keyboard keys: enter to confirm, shift to select, ↑ ↓ ← → are directions, Z and X correspond to handles B and A, and sometimes space is a selection, you can try it more.
For me, I just want to experience the nostalgia, 42 games are more than enough. For actual experience, please visit the blog: "Game World" - "Invincible DOS Game Library", or you can directly click:Unrivaled DOS game library.
Configuring public network access
If you want to publish to the public Internet, you need to choose the most suitable publishing method according to the actual environment and the reverse proxy you use. You can refer to my previous articles:
1,Docker series uses Docker to build its own reverse proxy based on NPM
2,Linux panel series configure reverse proxy and use non-443 port for publishing
3.Home data center series uses domestic cloud hosting to get free cloudflare to achieve fast access to domestic sites from abroad
4.Home Data Center Series: Use cloudflare to build a website quickly with no public IP in your home broadband (general purpose)
The first and second methods are suitable for environments with public IP but no legal 443 port (home broadband, unregistered cloud host). You need to add a non-standard port after the URL (if you use cloudflare to build a website, you don't need to add a port, but you need to customize the source station port. You can refer to:Home data center series uses cloudflare's Origin Rules to solve the problem of having a public IP but no legal ports 80 and 443 when building a websiteThe third method is suitable for cloud hosts with a record, and the fourth method is suitable for all environments (including environments without public IP), which is also the method I recommend (regardless of whether your environment has a public IP or not, because this method does not require running https traffic directly on the public network).