# Export realm settings with Keycloak in Docker

when exporting realm through Docker the following error happens:

I get the following error message:

```plaintext
ERROR: Error during export/import: /opt/keycloak/data/import/your-realm.json (Permission denied)
```

To resolve this, run the command using the root proveleges

`docker exec -u root -t -i <container_id> /bin/bash`

then execute the command to export `/opt/keycloak/bin/`[`kc.sh`](http://kc.sh) `export --dir /opt/keycloak/data/import --realm {your-realms-id} --users realm_file`

With `--dir` or `--file` you can specify the export folder or file. `--users realm_file` will cause that the users will be put into the realm file. `--realm {your-realms-id}` is used to specify which realm is supposed to be exported.

## [Copy exported realm file to hos](https://simonscholz.dev/tutorials/keycloak-realm-export-import#copy-exported-realm-file-to-host)[t](https://simonscholz.dev/tutorials/keycloak-realm-export-import#copy-exported-realm-file-to-host)

[Using `cat` to view the contents](https://simonscholz.dev/tutorials/keycloak-realm-export-import#copy-exported-realm-file-to-host) o[f the realm file is nice, but he](https://simonscholz.dev/tutorials/keycloak-realm-export-import#copy-exported-realm-file-to-host)re is the command to copy it over to your machine.

```plaintext
docker cp {your-containers-id}:/opt/keycloak/data/import/{your-realm-id}-realm.json /{your-desired-location-on-host}
```
