我有一个在容器Angular中运行的应用程序NginX Docker。
该Angular应用程序可以调用REST另一个容器(Spring BootAPI Docker)localhost作为服务器。
server: string = 'localhost';
return this.httpClient.post<MyClass[]>('http://' + this.server + ':6060/files-data/list-files', request);
Run Code Online (Sandbox Code Playgroud)
但REST使用Docker服务名称时调用会失败。
server: string = 'files-service';
return this.httpClient.post<MyClass[]>('http://' + this.server + ':8080/files-data/list-files', request);
Run Code Online (Sandbox Code Playgroud)
*这次使用8080端口来尝试解析docker服务名称
UI 控制台中出现错误:
net::ERR_NAME_NOT_RESOLVED
使用NginX带有 default 的默认图像nginx.conf。
nginx-files-ui:
image: nginx:latest
container_name: nginx-files-ui
volumes:
- ./files-ui/dist/html:/usr/share/nginx/html
ports:
- 99:80
Run Code Online (Sandbox Code Playgroud)
容器都在同一网络上运行Docker。
networks:
default:
external:
name: files-net
Run Code Online (Sandbox Code Playgroud)
修改nginx.conf为包括解析器但没有乐趣。
resolver 127.0.0.11 …
如何创建以第一个元素为键的列表列表:
从:
myList = [ [26, 'hello'], [26, 'hola'], [26, 'hi'], [26, 'bonjour'], [27, 'bye'],[27, 'doei'], [27, 'see you'], [27, 'tot ziens'] ]
Run Code Online (Sandbox Code Playgroud)
至:
[ [26, 'hello', 'hola', 'hi', 'bonjour'], [27, 'bye', 'doei', 'see you', 'tot ziens'] ]
Run Code Online (Sandbox Code Playgroud)