Fix docker rails error: tmp/pids/server.pid Not Cleaned Up

November 17, 2023 (1y ago)

Read on Dev.to →

If you work on a Rail app with Docker, you may encounter a docker rails error that says "A server is already running (pid: pid_number, file: /app/tmp/pids/server.pid)". I was frustrated when that happened to me, so I decided to write this article and show you how I fixed it. It's pretty simple in reality. Let's go!

#!/bin/bash
set -e
 
if [ -f tmp/pids/server.pid ]; then
  rm tmp/pids/server.pid
fi
 
exec bundle exec "$@" 

Start the Rails server

ENTRYPOINT ["docker-entrypoint.sh"] CMD ["rails", "server", "-b", "0.0.0.0"]

Run docker-compose up again and everything should be ok.

Comments (0)

Add Comment