在此示例中,仅当在mysql:3036
上暴露mysql容器时,我才想运行pyramida容器。我尝试使用wait-for-it.sh
,但如何在棱镜容器中使用它呢?
https://github.com/vishnubob/wait-for-it
version: '3.7'
services:
prisma:
image: prismagraphql/prisma:1.34.8
restart: always
depends_on:
- mysql
ports:
- '4466:4466'
environment:
PRISMA_CONFIG: |
port: 4466
databases:
default:
connector: mysql
host: mysql
user: root
password: prisma
rawAccess: true
port: 3306
migrations: true
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: prisma
volumes:
- ./persistence/test/mysql:/var/lib/mysql
redis:
image: redis:5-alpine
command: redis-server
ports:
- 6379:6379
volumes:
- ./persistence/test/redis:/data
hostname: redis
restart: always
# env_file: ${ENV_FILE}
答案 0 :(得分:1)
如果您想使用wait-for-it.sh
等待服务mysql:3036
可用,则必须构建自己的映像FROM prismagraphql/prisma:1.34.8
和COPY
{{1 }}到该图像。之后,您将必须创建一个自定义的启动脚本,该脚本将调用wait-for-it.sh
,然后调用wait-for-fit.sh
这是主要的prisma进程。
例如exec
Dockerfile
例如FROM prismagraphql/prisma:1.34.8
COPY wait-for-it.sh /
COPY entrypoint.sh /
RUN chmod +x /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
entrypoint.sh
棘手的部分是找出图像中的启动脚本。有时,您会在项目存储库中找到一个公共#!/usr/bin/env bash
/wait-for-it.sh mysql:3036 #add timeout if you want `-t 10s`
exec /app/start.sh "$@"
,或者您必须检查图像,例如Dockerfile