编写Dockerfile
[root@docker ~]# vim Dockerfile
FROM centos:7
ADD http://23126342.s21d-23.faiusrd.com/0/ABUIABAAGAAg1M3F9wUoxOzFiwY?f=BrowserQuest.tar.gz&v=1592878804 /
RUN yum install php-cli php-process php-devel php-pear libevent-devel -y && yum clean all
RUN tar xzvf /ABUIABAAGAAg1M3F9wUoxOzFiwY \
&& echo -e 'sed -i "s/hostip/$HOST_IP/g" /BrowserQuest/Web/config/config_local.json && php start.php start' > /BrowserQuest/run.sh
WORKDIR /BrowserQuest
EXPOSE 8000
EXPOSE 8787
CMD ["bash","run.sh"]
打包成镜像
[root@docker ~]# docker build -t rpggame .
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
rpggame latest ddfa457a0581 10 hours ago 310MB
kodcloud/kodbox latest 1e0f66c436a4 23 hours ago 471MB
httpd latest dabbfbe0c57b 9 months ago 144MB
ilemonrain/h5ai latest 25d4c087daaa 4 years ago 26.3MB
game2048 latest 19299002fdbe 5 years ago 55.5MB
运行
# 这里HOSTIP设置你的主机IP
[root@docker ~]# docker run -d -p 8000:8000 -p 8787:8787 --restart=always -e HOST_IP=xxx.xxx.xxx.xxx --name RPG rpggame
成功
ip:8787端口访问游玩