As I was working through the book, I encountered a problem where the web container refused to start using docker-compose.
- I was starting everything in the background (
-doption), so I didn’t see any errors. Two ways to get to thewebcontainer’s logs:docker-compose logs web-
docker-compose up webwill start the container in the foreground, and its logs will be sent to the terminal.
- 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.pidfiles 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 itspidfile around even though it’s not running. Deleting the file will solve the problem. -
docker-compose run web rm /usr/src/app/tmp/pids/server.pidto delete the file.
Problem solved!