# Could not write file \[/usr/share/elasticsearch/config/users\] bind mounted using docker-compose

**URL:** <https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046>\
**Category:** Elasticsearch\
**Tags:** docker\
**Created:** [February 23, 2022, 1:57pm UTC](https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046 "2022-02-23T13:57:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [February 23, 2022, 1:57pm UTC](https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046/1 "2022-02-23T13:57:49Z")

</div>

Continuing the discussion from ["Device or resource busy" when adding to keystore in Docker Compose](https://discuss.elastic.co/t/device-or-resource-busy-when-adding-to-keystore-in-docker-compose/228130/3):

I received a similar exception trying to execute a `bin/elasticsearch-users useradd` command:

```auto
Exception in thread "main" java.io.UncheckedIOException: could not write file [/usr/share/elasticsearch/config/users]
	at org.elasticsearch.xpack.security.support.SecurityFiles.writeFileAtomically(SecurityFiles.java:72)
	at org.elasticsearch.xpack.security.authc.file.FileUserPasswdStore.writeFile(FileUserPasswdStore.java:180)
	at org.elasticsearch.xpack.security.authc.file.tool.UsersTool$AddUserCommand.execute(UsersTool.java:130)
	at org.elasticsearch.cli.EnvironmentAwareCommand.execute(EnvironmentAwareCommand.java:77)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
	at org.elasticsearch.cli.MultiCommand.execute(MultiCommand.java:95)
	at org.elasticsearch.cli.Command.mainWithoutErrorHandling(Command.java:112)
	at org.elasticsearch.cli.Command.main(Command.java:77)
	at org.elasticsearch.xpack.security.authc.file.tool.UsersTool.main(UsersTool.java:48)
Caused by: java.nio.file.FileSystemException: /usr/share/elasticsearch/config/users11882566129646724999tmp -> /usr/share/elasticsearch/config/users: Device or resource busy
	at java.base/sun.nio.fs.UnixException.translateToIOException(UnixException.java:100)
	at java.base/sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:106)
	at java.base/sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:416)
	at java.base/sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:267)
	at java.base/java.nio.file.Files.move(Files.java:1432)
	at org.elasticsearch.xpack.security.support.SecurityFiles.writeFileAtomically(SecurityFiles.java:67)

```

The users file is bind-mounted into the container.  
Is there a solution to this that uses docker-compose without a custom Dockerfile?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [February 24, 2022, 9:24am UTC](https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046/2 "2022-02-24T09:24:03Z")

</div>

Have you checked if the bind mount is writable? I think that works via `docker inspect` on top of my head...

---

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [February 24, 2022, 10:35am UTC](https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046/3 "2022-02-24T10:35:51Z")

</div>

It seems to be... 🤔

```auto
            {
                "Type": "bind",
                "Source": "/home/ubuntu/ro-elasticsearch/users",
                "Destination": "/usr/share/elasticsearch/config/users",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [March 24, 2022, 10:36am UTC](https://discuss.elastic.co/t/could-not-write-file-usr-share-elasticsearch-config-users-bind-mounted-using-docker-compose/298046/4 "2022-03-24T10:36:22Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
