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 (
-d
option), so I didn’t see any errors. Two ways to get to theweb
container’s logs:docker-compose logs web
-
docker-compose up web
will 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.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 itspid
file 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.pid
to delete the file.
Problem solved!