我有这个 docker-compose.yaml。它使用公共 API 定义了 1 个服务和 4 个服务(复制的),每个服务有另外两个微服务(一个接收事件,另一个将信息保存到 mongo)。当我执行“docker-compose up”时,这非常有效。但我想用“docker run”运行每个图像。
version: "3.3"
services:
api:
build:
context: .
image: monitor-log-public
#container_name: monitor-log-public
env_file: docker-compose.env
environment:
SERVICES: api
PORT: 3000
#depends_on:
# - redis
labels:
- "traefik.enable=false"
- "traefik.http.routers.api-gw.rule=PathPrefix(`/`)"
- "traefik.http.services.api-gw.loadbalancer.server.port=3000"
networks:
- internal
ports:
- 3000:3000
monitor-1:
build:
context: .
image: monitor-log-monitor-1
#container_name: monitor-log-logger
env_file: docker-compose.env
environment:
SERVICES: monitor,logs.db
#depends_on:
# - redis
networks:
- internal
monitor-2:
build:
context: .
image: monitor-log-monitor-2
#container_name: monitor-log-logger
env_file: docker-compose.env
environment:
SERVICES: monitor,logs.db
#depends_on:
# - redis
networks:
- internal
monitor-3:
build:
context: .
image: monitor-log-monitor-3
#container_name: monitor-log-logger
env_file: docker-compose.env
environment:
SERVICES: monitor,logs.db
#depends_on:
# - redis
networks:
- internal
monitor-4:
build:
context: .
image: monitor-log-monitor-4
#container_name: monitor-log-logger
env_file: docker-compose.env
environment:
SERVICES: monitor,logs.db
#depends_on:
# - redis
networks:
- internal
#redis:
# image: redis:alpine
# networks:
# - internal
networks:
internal:
internal: false
volumes:
data:
当我执行“撰写运行监视器日志公共”时,执行会因任何原因而关闭。
c:\temp\monitor-log-image>docker run monitor-log-monitor-1
[2021-02-22T08:51:42.449Z] INFO b304e268d414-1/BROKER: Moleculer v0.14.12 is starting...
[2021-02-22T08:51:42.451Z] INFO b304e268d414-1/BROKER: Namespace: <not defined>
[2021-02-22T08:51:42.451Z] INFO b304e268d414-1/BROKER: Node ID: b304e268d414-1
[2021-02-22T08:51:42.452Z] INFO b304e268d414-1/REGISTRY: Strategy: RoundRobinStrategy
[2021-02-22T08:51:42.452Z] INFO b304e268d414-1/REGISTRY: Discoverer: LocalDiscoverer
[2021-02-22T08:51:42.453Z] INFO b304e268d414-1/BROKER: Serializer: JSONSerializer
[2021-02-22T08:51:42.458Z] INFO b304e268d414-1/BROKER: Validator: FastestValidator
[2021-02-22T08:51:42.459Z] INFO b304e268d414-1/BROKER: Registered 13 internal middleware(s).
[2021-02-22T08:51:42.471Z] INFO b304e268d414-1/REGISTRY: '$node' service is registered.
[2021-02-22T08:51:42.472Z] INFO b304e268d414-1/$NODE: Service '$node' started.
[2021-02-22T08:51:42.473Z] INFO b304e268d414-1/BROKER: ✔ ServiceBroker with 1 service(s) is started successfully in 6ms.
[2021-02-22T08:51:42.474Z] INFO b304e268d414-1/$NODE: Service '$node' stopped.
[2021-02-22T08:51:42.474Z] INFO b304e268d414-1/BROKER: ServiceBroker is stopped. Good bye.
我可以看到这个执行不知道需要加载“api”服务,但这是在 docker-compose.yaml 中定义的,为什么图像没有读取?