# Import Realm with docker-compose setup

**URL:** <https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903>\
**Category:** Configuring the server\
**Created:** [May 7, 2024, 1:38pm UTC](https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903 "2024-05-07T13:38:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![maho01](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/maho01/32/10118_2.png) [@maho01](https://forum.keycloak.org/u/maho01)\
**Post date:** [May 7, 2024, 1:38pm UTC](https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903/1 "2024-05-07T13:38:17Z")

</div>

Is there a way to import a Realm with env\_variables like KEYCLOAK\_IMPORT.

But keycloak\_import seems to be deprecated.

I´m using KC\_FILE, with a mounted file, but this does not work.

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [May 7, 2024, 1:43pm UTC](https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903/2 "2024-05-07T13:43:16Z")

</div>

> **[Importing and Exporting Realms - Keycloak](https://www.keycloak.org/server/importExport#_importing_a_realm_during_startup)**
>
> Keycloak is an open source identity and access management solution

It’s all in there… in the docs/guides!

---

<div class="post-metadata">

**Author:** ![maho01](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/maho01/32/10118_2.png) [@maho01](https://forum.keycloak.org/u/maho01)\
**Post date:** [May 7, 2024, 2:01pm UTC](https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903/3 "2024-05-07T14:01:24Z")

</div>

Ok so the solution is changing the docker-compose to:

```auto
command:
   start --import-realm

```

and mount the realm in `/opt/keycloak/data/import`

Thanks so far!

But why is there an env KC\_FILE? Is it to import on build but not on startup?

---

<div class="post-metadata">

**Author:** ![dasniko](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/dasniko/32/2969_2.png) [@dasniko](https://forum.keycloak.org/u/dasniko)\
**Post date:** [May 7, 2024, 2:06pm UTC](https://forum.keycloak.org/t/import-realm-with-docker-compose-setup/25903/4 "2024-05-07T14:06:31Z")

</div>

> [@maho01](#):
>
> But why is there an env KC\_FILE? Is it to import on build but not on startup?

Not on `build` and not on `start`, it’s only for `export` and `import`.
