我正在尝试使用 docker compose 为我的模拟 api 运行模拟 docker cli,并且我已将 json 导出到我的目录中,
version: "3"
services:
mockoon:
image: mockoon/cli:latest
command: mockoon-cli start
networks:
demo:
ports:
- "8001:8001"
volumes:
- type: bind
source: ./mock.json
target: /www
networks:
demo:
当我运行 docker-compose up 时,容器会启动几秒钟,然后关闭并显示以下日志
› Error: Missing required flag:
› -d, --data DATA Path(s) or URL(s) to your Mockoon data file(s)
› See more help with --help
我应该进行的任何其他设置,或者我在配置中遗漏了某些内容。
我查了官方文档,需要在 docker-compose
--data
行里面指定 command
目录。
所以撰写文件会像这样:
version: "3"
services:
mockoon:
image: mockoon/cli:latest
command: mockoon-cli start --data <directory> # this is where the change takes place
networks:
demo:
ports:
- "8001:8001"
volumes:
- type: bind
source: ./mock.json
target: /www
networks:
demo:
--data 标志后面的“data”是文件名的别名,而不是文件夹名称。因此,它应该是:
version: "3"
services:
chicargo-mockoon-mock:
platform: linux/amd64
image: mockoon/cli:latest
ports:
- "8001:8001"
volumes:
- type: bind
source: ./your-file-name.json
target: /data
command: mockoon-cli start --data data
面对类似的问题,发现:
mockoon-cli start
包含到 command:
中,因为它已包含在 ENTRYPOINT 中。
这对我有用:version: "3"
services:
mockoon-mock:
image: mockoon/cli
command: ["--data", "data"]
ports:
- "8001:8001"
volumes:
- ./myFolder/myEnvironmentFile.json:/data