# Error: Cannot write pid file to {path\_string}

**URL:** <https://forums.docker.com/t/error-cannot-write-pid-file-to-path-string/118435>\
**Category:** General\
**Tags:** docker, build\
**Created:** [December 6, 2021, 6:35am UTC](https://forums.docker.com/t/error-cannot-write-pid-file-to-path-string/118435 "2021-12-06T06:35:43Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dirobaloska](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dirobaloska](https://forums.docker.com/u/dirobaloska)\
**Post date:** [December 6, 2021, 6:35am UTC](https://forums.docker.com/t/error-cannot-write-pid-file-to-path-string/118435/1 "2021-12-06T06:35:43Z")

</div>

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

 ![image](https://global.discourse-cdn.com/docker/original/3X/9/4/94104fb49b8d8e6234001ea4aaa52ad9aad0475b.png)

This is the configuration in docker-compose.yml

```auto
database:
    container_name: qrcodesite_db
    image: mongo
    ports :
      - 27017:27017
    command : ["mongod"]
    volumes :
      - ./db-volume:/data/db:rw
      - ./temp:/temp:rw
    environment:
      - MONGO_INITDB_ROOT_USERNAME=
      - MONGO_INITDB_ROOT_PASSWORD=
      - MONGO_INITDB_DATABASE=

```

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.

---

<div class="post-metadata">

**Author:** ![rimelek](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/rimelek/32/41602_2.png) [@rimelek](https://forums.docker.com/u/rimelek)\
**Post date:** [December 6, 2021, 7:02pm UTC](https://forums.docker.com/t/error-cannot-write-pid-file-to-path-string/118435/2 "2021-12-06T19:02:19Z")

</div>

> [@dirobaloska](#):
>
> mounting the volume for /temp

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:

```bash
# 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'

```

---

<div class="post-metadata">

**Author:** ![dirobaloska](https://avatars.discourse-cdn.com/v4/letter/d/85f322/32.png) [@dirobaloska](https://forums.docker.com/u/dirobaloska)\
**Post date:** [December 7, 2021, 10:41am UTC](https://forums.docker.com/t/error-cannot-write-pid-file-to-path-string/118435/3 "2021-12-07T10:41:26Z")

</div>

> [@rimelek](#):
>
> ```auto
> docker run --rm -it mongo ls -la /tmp
> 
> ```

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