go聊天室项目docker部署

查看构建镜像中的文件

docker run -it --rm chatroom-chatroom-server sh

ls -la /root/

清理并重新构建

docker-compose down

docker-compose build

docker-compose up -d

docker项目部署:

1.环境准备:

bash 复制代码
# 安装 Go 语言环境
sudo apt install golang-go

2.项目配置

bash 复制代码
# 创建项目目录
mkdir -p /home/www/project/chatroom
cd /home/www/project/chatroom

# 初始化 Go 模块
go mod init chatroom
  1. Docker 部署
bash 复制代码
# 构建并启动容器
docker-compose up -d

# 查看容器状态
docker ps

# 查看日志
docker logs chatroom-server

4.客户端连接

bash 复制代码
# 在虚拟机内运行客户端
go run client/client.go

5.网络测试

bash 复制代码
# 测试端口连接
telnet <服务器IP> 8888

💡 提示:在虚拟机内部,客户端使用 127.0.0.1 连接服务器是正确的。如果需要从外部访问,需要修改为虚拟机的公网IP。

相关推荐
虎头金猫3 天前
4K 视频总卡在公网带宽?用 N1 + OpenList 把网盘播放链路重新理顺
运维·服务器·网络·python·容器·beautifulsoup·pandas
分布式存储与RustFS3 天前
MinIO 官方 Docker 镜像被移除:依赖它的项目该怎么办
docker·云原生·devops·对象存储·minio·分布式存储
AI职业加油站3 天前
AI智能体应用工程师证书:政策红利下的职业新风口
大数据·运维·人工智能·学习·职场发展
此冬歌咏3 天前
K8s 节点故障实战:优雅驱逐 31 秒,硬故障 331 秒,以及那个永远 Pending 的 Pod
运维·k8s
玉&心3 天前
通过Arthas在线诊断K8S中的内存及JVM等使用情况
docker·k8s·arthas
xing-xing3 天前
Docker容器中Nginx站点根目录网页配置访问
nginx·docker
-梅3 天前
linux(8) 软硬链接
linux·运维·服务器
赵文宇(温玉)3 天前
CoreDNS的hosts插件的缺行配置导致k8s集群异常
容器·kubernetes·rancher
guo_wen_qiang3 天前
上传本地镜像到harbor中
docker·容器·持续部署
张洛闻Eren3 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github