Docker for Rails Developers: A solution for the web container not starting

As I was working through the book, I encountered a problem where the web container refused to start using docker-compose.

  1. I was starting everything in the background (-d option), so I didn’t see any errors. Two ways to get to the web container’s logs:
    1. docker-compose logs web
    2. docker-compose up web will start the container in the foreground, and its logs will be sent to the terminal.
  2. The logs told me that Rails thought that there was already a server running, and it pointed me to /usr/src/app/tmp/pids/server.pid.
    I know that .pid files are essentially mutexes that some processes use to prevent that process from being launched twice. Sometimes a process can be stopped and not clean up after itself, leaving its pid file around even though it’s not running. Deleting the file will solve the problem.
  3. docker-compose run web rm /usr/src/app/tmp/pids/server.pid to delete the file.

Problem solved!

1 Like