Docker-Compose部署ASPNETCore7
一、安装Compose
1、环境准备:
Linux-CentOS7
2、安装命令
#执行命令
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
#执行命令授权
sudo chmod +x /usr/local/bin/docker-compose
检查是否安装成功
docker-compose --version
3、在项目中添加Dockerfile文件
4、准备Docker-compose文件
version: '3.3'
services:
net7web:
build:
context: Demo.NET7Demo/
dockerfile: Demo.NET7Demo/Zhaoxi.NET7.WebApplication/Dockerfile
image: net7web:20221114
container_name: "net7webContainer"
ports:
- 8001:80/tcp
command: ["dotnet", "/app/Zhaoxi.NET7.WebApplication","--urls=http://*:80","--ip=127.0.0.1","--port=8001"]
5、上传整个解决方案到Linux系统
6、进入项目和Docker-compose文件目录下执行命令:
docker-compose up