一、本次实践介绍
1. 本次实践简介
本次实践部署环境为个人测试环境,快速使用docker部署RPG网页小游戏。
root@WellDone:/home/goodjob# uname -a
Linux WellDone 6.5.0-14-generic #14~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Mon Nov 20 18:15:30 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
2. 本地环境规划
本次实践环境规划:
启动镜像后的名字 | IP地址 | 容器镜像版本 | 操作系统版本 |
---|---|---|---|
games | 192.168.20.8 | latest | ubuntu 22.04 |
三、Docker环境
1.检查本地Docker版本
检查Docker版本:docker version
root@WellDone:/home/goodjob# docker version
Client: Docker Engine - Community
Version: 25.0.0
API version: 1.44
Go version: go1.21.6
Git commit: e758fe5
Built: Thu Jan 18 17:09:49 2024
OS/Arch: linux/amd64
Context: default
Server: Docker Engine - Community
Engine:
Version: 25.0.0
API version: 1.44 (minimum version 1.24)
Go version: go1.21.6
Git commit: 615dfdf
Built: Thu Jan 18 17:09:49 2024
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.6.27
GitCommit: a1496014c916f9e62104b33d1bb5bd03b0858e59
runc:
Version: 1.1.11
GitCommit: v1.1.11-0-g4bccb38
docker-init:
Version: 0.19.0
GitCommit: de40ad0
2. 检查Docker服务状态
检查Docker服务状态,确保Docker服务正常运行。
systemctl status docker
root@WellDone:/home/goodjob# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-01-24 08:54:31 CST; 7h ago
TriggeredBy: ● docker.socket
Docs: https://docs.docker.com
Main PID: 1549 (dockerd)
Tasks: 66
Memory: 178.0M
CPU: 6.959s
CGroup: /system.slice/docker.service
├─ 1549 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
├─ 2010 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 6379 -container-ip 172.17.0.2 -container-port 6379
├─ 2016 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 6379 -container-ip 172.17.0.2 -container-port 6379
├─ 2029 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 5432 -container-ip 172.17.0.3 -container-port 5432
├─ 2036 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 5432 -container-ip 172.17.0.3 -container-port 5432
├─26709 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 8888 -container-ip 172.17.0.4 -container-port 80
└─26716 /usr/bin/docker-proxy -proto tcp -host-ip :: -host-port 8888 -container-ip 172.17.0.4 -container-port 80
1月 24 08:54:30 WellDone dockerd[1549]: time="2024-01-24T08:54:30.147900140+08:00" level=info msg="Starting up"
1月 24 08:54:30 WellDone dockerd[1549]: time="2024-01-24T08:54:30.150167308+08:00" level=info msg="detected 127.0.0.53 nameserver, assuming syste>
1月 24 08:54:30 WellDone dockerd[1549]: time="2024-01-24T08:54:30.222187838+08:00" level=info msg="[graphdriver] using prior storage driver: over>
1月 24 08:54:30 WellDone dockerd[1549]: time="2024-01-24T08:54:30.253670047+08:00" level=info msg="Loading containers: start."
1月 24 08:54:30 WellDone dockerd[1549]: time="2024-01-24T08:54:30.660930678+08:00" level=info msg="Default bridge (docker0) is assigned with an I>
1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.025018910+08:00" level=info msg="Loading containers: done."
1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.037721980+08:00" level=info msg="Docker daemon" commit=615dfdf containerd-snaps>
1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.037911963+08:00" level=info msg="Daemon has completed initialization"
1月 24 08:54:31 WellDone dockerd[1549]: time="2024-01-24T08:54:31.067895045+08:00" level=info msg="API listen on /run/docker.sock"
1月 24 08:54:31 WellDone systemd[1]: Started Docker Application Container Engine.
四、部署RPG网页小游戏
1. 下载RPG网页小游戏容器镜像
为了方便下载,已经在我的阿里云镜像仓库上传,拉取镜像:docker pull 镜像
docker pull registry.cn-guangzhou.aliyuncs.com/welldene/games:rpg_game
2. 创建RPG网页小游戏容器
使用docker-cli快速创建RPG网页小游戏的容器。
docker run -d -p 8000:8000 -p 8787:8787 --name rpg -e HOST_IP=192.168.10.153 registry.cn-guangzhou.aliyuncs.com/welldene/games:rpg_game
root@WellDone:/home/goodjob# docker run -d -p 8000:8000 -p 8787:8787 --name rpg -e HOST_IP=192.168.10.153 registry.cn-guangzhou.aliyuncs.com/welldene/games:rpg_game
0704a1acc51f6779e679ba9cb6ef4261a5b0bfcb446723f20c2fab27d26203e7
3. 检查容器运行状态
检查容器的运行状态,确保RPG网页小游戏的正常运行。
docker ps
五、访问RPG网页小游戏的web页面
访问RPG网页小游戏首页 访问地址:http://192.168.20.8:8787/
1.创建角色
2.开始游戏