You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Nginx/backend-demo/build_run_docker.md

15 lines
773 B

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

构建docker镜像
```shell
docker build -t nudt-demo:1.0 .
```
运行docker镜像
```shell
docker run -d -p 8080:8080 -e demo.server.name=test1 nudt-demo:1.0
```
注意哦,其中`demo.server.name`是容器的名称,可自定义,例如,要启动两个容器实例,可执行:
```shell
docker run -d --network nudt --network-alias server1 -p 8080:8080 -e demo.server.name=server1 nudt-demo:1.0
docker run -d --network nudt --network-alias server2 -p 8081:8080 -e demo.server.name=server2 nudt-demo:1.0
```
其中,`--network nudt`表示将当前容器加入名为nudt的网络如果该网络不存在需要提前使用`docker network create nudt`命令创建网络;`--network-alias <alias-name>`表示将当前容器的网络主机名设置为`alias-name`