# Can't drop-in Percona-Server-MongoDB image without errors

**URL:** <https://forums.percona.com/t/cant-drop-in-percona-server-mongodb-image-without-errors/16333>\
**Category:** Percona Server for MongoDB\
**Created:** [June 27, 2022, 5:09pm UTC](https://forums.percona.com/t/cant-drop-in-percona-server-mongodb-image-without-errors/16333 "2022-06-27T17:09:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samuelbailor](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@samuelbailor](https://forums.percona.com/u/samuelbailor)\
**Post date:** [June 27, 2022, 5:09pm UTC](https://forums.percona.com/t/cant-drop-in-percona-server-mongodb-image-without-errors/16333/1 "2022-06-27T17:09:07Z")

</div>

I am currently creating a Docker Container with the following image:

```auto
FROM mongo
EXPOSE 27017

```

This pulls the latest mongo official docker image from DockerHub.  
I was hoping to drop-in percona’s mongo image to replace the official, but I’m running into an issue. This is what the dockerfile looks like:

```auto
FROM percona/percona-server-mongodb
EXPOSE 27017

```

The container builds fine, but when I try to spinup my deployment environment with docker compose up, I get the following issue:

```auto
mongo_1 | {"t":{"$date":"2022-06-27T17:05:17.030+00:00"},"s":"E",  
"c":"CONTROL", "id":20557, "ctx":"initandlisten",
"msg":"DBException in initAndListen, terminating",
"attr":{"error":"IllegalOperation: Attempted to create a lock file on a read-only directory: /data/db"}
}

```

Once the lock file error happens, everything shuts down

---

<div class="post-metadata">

**Author:** ![samuelbailor](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@samuelbailor](https://forums.percona.com/u/samuelbailor)\
**Post date:** [June 27, 2022, 8:16pm UTC](https://forums.percona.com/t/cant-drop-in-percona-server-mongodb-image-without-errors/16333/2 "2022-06-27T20:16:25Z")

</div>

I fixed the above issue by changing permissions on the `database/` collection within my deployment folder. This is not an issue I had in the past with mongo’s image, so I’m unsure as to why I’m getting it now.

Anyways, even with this issue fixed, I’m still having errors replacing the official mongo image with the Percona-Server-MongoDB container. I am currently getting a `ECONNREFUSED for localhost:27017 MongoNetworkError`

---

<div class="post-metadata">

**Author:** ![radoslaw.szulgo](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/radoslaw.szulgo/32/17315_2.png) [@radoslaw.szulgo](https://forums.percona.com/u/radoslaw.szulgo)\
**Post date:** [July 22, 2024, 10:31am UTC](https://forums.percona.com/t/cant-drop-in-percona-server-mongodb-image-without-errors/16333/3 "2024-07-22T10:31:01Z")

</div>

The problem is that the directory you created, `/data/db` is owned by and only writable by the root user, but you are running mongod as yourself. There are several ways to resolve this, but ultimately, you must give the directory in question the right permissions. For example:

```auto
sudo chmod -R go+w /data/db
sudo chown -R $USER /data/db

```

As for the latter issue, `ECONNREFUSED` error: There are few reasons for this error in node :

1. Your port is already occupied so it will refuse your connection. Go to the command line and get PID by using the following command:

```auto
$ lsof -i:port_number`

```

Now kill pid by using:

```auto
$ kill -9 pid

```

(you will get paid by the previous command)

1. There is also the possibility you need to run `mongod --repair `
