Docker Community Forums

Share and learn in the Docker community.

Error: Cannot write pid file to {path_string}

HELP I am having this error everytime I start docker container.

This is the configuration in docker-compose.yml

    container_name: qrcodesite_db
    image: mongo
    ports :
      - 27017:27017
    command : ["mongod"]
    volumes :
      - ./db-volume:/data/db:rw
      - ./temp:/temp:rw

The command is something that i wanted to try to ommit the --fork option but does not help either. Also tried mounting the volume for /temp. This is an ubuntu server btw. Weird thing is I tested the config on Docker for Windows at other ubuntu server and it worked. I also don’t know how to recreate the problem.

It is /tmp in the error message, not /temp but I don’t think this is the solution. You should check why it cannot write /tmp. Run the mongo container from the command line and check folder permissions:

# as root
docker run --rm -it mongo ls -la /tmp
docker run --rm -it mongo mount
docker run --rm -it mongo bash -c 'touch /tmp/test.txt && ls -la /tmp'

# as mongodb
docker run --rm -it --user mongodb mongo bash -c 'touch /tmp/test.txt && ls -la /tmp'

Thanks for the reply.
Everything else beside as mongodb works.