You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何调用Redmine Docker镜像入口点?解决容器启动早于数据库问题

Fixing Redmine 3.3 Container Startup Failure Due to Database Order

Hey there! I totally get the frustration when containers start out of order—let's get your Redmine instance up and running smoothly. Here's how to add a delay or properly wait for the database before starting Redmine:

1. Quick Fix: Add a Sleep Delay with command

The official Redmine 3.3 image uses /docker-entrypoint.sh as its entrypoint, and the default command is rails server -b 0.0.0.0. When you want to add a sleep, you need to wrap both the delay and the full startup sequence in a shell command.

For Docker Run:

docker run -d \
  --name redmine \
  # Add your other flags (ports, volumes, links to DB, etc.) here \
  redmine:3.3 \
  bash -c "sleep 15 && /docker-entrypoint.sh rails server -b 0.0.0.0"

For Docker Compose:

Add this to your docker-compose.yml under the Redmine service:

services:
  redmine:
    image: redmine:3.3
    command: bash -c "sleep 15 && /docker-entrypoint.sh rails server -b 0.0.0.0"
    # Your other config (ports, volumes, depends_on) goes here
    depends_on:
      - db

Why this works: We're using bash -c to run a sequence of commands—first wait 15 seconds (adjust the number based on your database's startup time), then call the entrypoint script with the exact default command it expects.

2. More Reliable: Wait for Database Readiness (Better Than Fixed Sleep)

A fixed sleep can be hit-or-miss (sometimes your DB takes longer to start). A better approach is to use a script that waits until the database is actually reachable.

Step 1: Prepare the wait-for-it script

Save the wait-for-it.sh script locally (it's a simple utility that checks if a service is up).

Step 2: Update Your Command

Assuming you've mounted wait-for-it.sh to /usr/local/bin/wait-for-it.sh and your database service is named db on port 3306:

Docker Compose Example:

services:
  redmine:
    image: redmine:3.3
    command: bash -c "wait-for-it.sh db:3306 -t 30 && /docker-entrypoint.sh rails server -b 0.0.0.0"
    volumes:
      - ./wait-for-it.sh:/usr/local/bin/wait-for-it.sh
      - ./redmine-data:/usr/src/redmine/files
    depends_on:
      - db
    ports:
      - "3000:3000"

This will wait up to 30 seconds for the database at db:3306 to be ready before starting Redmine—no more guesswork with sleep times!

Why Your Earlier Attempt Might Have Failed

If you just tried running /docker-entrypoint.sh without arguments, the script doesn't know what process to start. It expects the default Rails server command as an argument, which is why we need to include rails server -b 0.0.0.0 after it.

内容的提问来源于stack exchange,提问作者Sebastien Diot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.12 04:07:52