{"id":132890,"date":"2026-05-23T23:32:52","date_gmt":"2026-05-23T23:32:52","guid":{"rendered":"\/uk\/tutorials\/how-to-install-directus-docker"},"modified":"2026-05-23T23:32:52","modified_gmt":"2026-05-23T23:32:52","slug":"how-to-install-directus-docker","status":"publish","type":"post","link":"\/uk\/tutorials\/how-to-install-directus-docker","title":{"rendered":"How to turn a database into a CMS and API with Directus and Docker"},"content":{"rendered":"<p>Directus with Docker lets you run a self-hosted headless CMS that turns a SQL database into a content management system and an auto-generated API. You can install Directus manually with Docker Compose or deploy it faster using Hostinger&rsquo;s Directus Docker template.<\/p><p>To set up Directus, you&rsquo;ll need a server or local machine with Docker, Docker Compose, persistent storage, and a secure secret key. After installation, you can open Directus Studio, create collections, manage content visually, and expose selected data through REST or GraphQL endpoints for your website, app, or internal tool.<\/p><h2 class=\"wp-block-heading\" id=\"h-what-do-you-need-before-installing-directus-with-docker\">What do you need before installing Directus with Docker?<\/h2><p>Before installing Directus with <a href=\"\/uk\/tutorials\/what-is-docker\">Docker<\/a>, make sure you have:<\/p><ul class=\"wp-block-list\">\n<li><strong>A server or local machine<\/strong> &ndash; use a <a href=\"\/uk\/vps\">VPS<\/a> for a public Directus deployment or a local machine for testing.<\/li>\n\n\n\n<li><strong>Docker installed<\/strong> &ndash; Directus runs inside a Docker container.<\/li>\n\n\n\n<li><strong>Docker Compose installed<\/strong> &ndash; use it to define the Directus container, ports, volumes, and environment variables.<\/li>\n\n\n\n<li><strong>A database option<\/strong> &ndash; use SQLite for testing or PostgreSQL\/MySQL for production projects.<\/li>\n\n\n\n<li><strong>Persistent storage<\/strong> &ndash; create folders for the database, uploads, and extensions so your data remains after container restarts.<\/li>\n\n\n\n<li><strong>A secure secret key<\/strong> &ndash; Directus uses the SECRET value to sign tokens and protect authentication.<\/li>\n\n\n\n<li><strong>A domain or server IP address<\/strong> &ndash; use this to access the Directus Studio interface in your browser.<\/li>\n<\/ul><h2 class=\"wp-block-heading\" id=\"h-how-to-install-directus-with-docker\">How to install Directus with Docker<\/h2><p>Installing Directus with Docker lets you run the headless CMS in an isolated container with its required runtime, configuration, and dependencies. The fastest setup uses the official directus\/directus Docker image, while the recommended setup uses Docker Compose with persistent storage for the database, uploads, and extensions.<\/p><h3 class=\"wp-block-heading\">1. Check that Docker is installed<\/h3><p>Directus requires <a href=\"\/uk\/tutorials\/how-to-install-docker-on-ubuntu\">Docker to be installed on your server<\/a>. Check your Docker version with:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker --version<\/pre><p>Then check whether <a href=\"\/uk\/tutorials\/what-is-docker-compose\">Docker Compose<\/a> is available:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose version<\/pre><p>If both commands return version numbers, you can continue with the installation.<\/p><h3 class=\"wp-block-heading\">2. Create a Directus project directory<\/h3><p>Create a new directory for your Directus project. This directory will store the Docker Compose file and the folders Directus needs to keep data after the container restarts.<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir directus\ncd directus\nmkdir database uploads extensions<\/pre><p>The database folder stores the SQLite database file, uploads stores media files, and extensions stores custom Directus extensions.<\/p><h3 class=\"wp-block-heading\">3. Create a Docker Compose file<\/h3><p>Create a docker-compose.yml file inside the directus directory:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano docker-compose.yml<\/pre><p>Add the following configuration:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">services:\ndirectus:\nimage: directus\/directus:11.17.0\nports:\n- 8055:8055\nvolumes:\n- .\/database:\/directus\/database\n- .\/uploads:\/directus\/uploads\n- .\/extensions:\/directus\/extensions\nenvironment:\nSECRET: \"replace-this-with-a-long-random-value\"\nDB_CLIENT: \"sqlite3\"\nDB_FILENAME: \"\/directus\/database\/data.db\"\nWEBSOCKETS_ENABLED: \"true\"<\/pre><p>This configuration starts Directus on port 8055, stores Directus data outside the container, and uses SQLite as the database engine. SQLite is suitable for testing, small projects, and local development. For production websites or applications, use PostgreSQL or MySQL instead.<\/p><p>Replace replace-this-with-a-long-random-value with a secure secret. Directus uses this value to sign access tokens, so don&rsquo;t reuse simple passwords or public strings.<\/p><h3 class=\"wp-block-heading\">4. Start the Directus container<\/h3><p>Run the following command from the same directory as your docker-compose.yml file:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose up -d<\/pre><p>The -d option runs Directus in detached mode, so the container keeps running in the background.<\/p><p>Check whether the container is active:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker ps<\/pre><p>You should see a running container based on the directus\/directus image.<\/p><h3 class=\"wp-block-heading\">5. Open the Directus setup screen<\/h3><p>Open Directus in your browser using your server IP address or local machine address:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/localhost:8055<\/pre><p>If you installed Directus on a VPS, use:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055<\/pre><p>Directus will show the onboarding screen on first launch. Create your first admin account by entering your email, password, and project details.<\/p><h3 class=\"wp-block-heading\">6. Verify that Directus is running<\/h3><p>After creating the admin account, test the Directus server with the \/server\/ping endpoint:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055\/server\/ping<\/pre><p>A working Directus instance returns:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pong<\/pre><p>You can also check the container logs if the page doesn&rsquo;t load:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose logs directus<\/pre><h3 class=\"wp-block-heading\">7. Stop or restart Directus<\/h3><p>To stop the Directus container, run:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose down<\/pre><p>To start it again, run:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">docker compose up -d<\/pre><p>Because the Compose file mounts the database, uploads, and extensions folders as volumes, your Directus project data remains available after restarting the container.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-deploy-directus-with-hostingers-docker-template\">How to deploy Directus with Hostinger&rsquo;s Docker template<\/h2><p>Hostinger&rsquo;s <a href=\"\/uk\/vps\/docker\">Docker catalog<\/a> lets you deploy Directus on a VPS without manually pulling the Docker image, creating a Docker Compose file, or configuring the container from scratch. This option is best if you want a faster way to launch a self-hosted headless CMS and start building a database-backed API.<\/p><p>To deploy Directus with Hostinger&rsquo;s Docker template:<\/p><ol class=\"wp-block-list\">\n<li>Go to Hostinger&rsquo;s <a href=\"\/uk\/vps\/docker\/directus\">Directus Docker template<\/a> page.<\/li>\n\n\n\n<li>Choose a VPS plan for your project.<\/li>\n\n\n\n<li>Select the Directus template from the Docker application catalog.<\/li>\n\n\n\n<li>Complete the VPS setup.<\/li>\n\n\n\n<li>Open the deployed Directus instance from hPanel or by using your server IP address.<\/li>\n\n\n\n<li>Create your first Directus admin account on the onboarding screen.<\/li>\n<\/ol><p>After deployment, Directus runs as a Docker application on your VPS. You can use Hostinger&rsquo;s Docker manager to check the container status, view logs, and manage updates without setting up the container manually through the command line.<\/p><p>Open your Directus instance in the browser using the access URL provided in hPanel. If you&rsquo;re using the server IP address directly, the URL usually follows this format:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055<\/pre><p>To check whether Directus is responding, open the server ping endpoint:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055\/server\/ping<\/pre><p>A working Directus instance returns:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">pong<\/pre><p>Once Directus is running, create your first collection in Directus Studio and configure roles and permissions before exposing the API to a website or application. For a production setup, <a href=\"\/uk\/tutorials\/how-to-point-domain-to-vps\">connect a domain or subdomain<\/a>, enable HTTPS, and set up backups for the database, uploaded files, and project configuration.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-use-directus-as-a-headless-cms-and-data-api\">How to use Directus as a headless CMS and data API<\/h2><p>After installing Directus, you can use it to manage database content through a visual CMS interface and access the same content through automatically generated APIs. This makes Directus useful for websites, mobile apps, internal tools, and frontend frameworks that need structured content from a central database.<\/p><p>Start by creating a collection in Directus Studio. A collection works like a database table and defines the type of content you want to manage. For example, a blog can use collections like posts, authors, and categories, while a product catalog can use products, brands, and specifications.<\/p><p>Next, add fields to each collection. Fields define the structure of your content, such as text inputs, images, dates, dropdowns, relationships, and status values. For a posts collection, you can add fields like:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">title\nslug\ncontent\nfeatured_image\nstatus\npublished_at\nauthor<\/pre><p>Directus uses these collections and fields to create an admin interface for editors. Instead of updating database rows manually, team members can add and edit content from Directus Studio. This makes the database easier to manage without removing developer control over the underlying data model.<\/p><p>Directus also creates API endpoints for your collections. For example, a posts collection becomes available through the REST API:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055\/items\/posts<\/pre><p>You can request one item by its ID:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055\/items\/posts\/1<\/pre><p>If your project uses GraphQL, Directus exposes a GraphQL endpoint as well:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">http:\/\/your-server-ip:8055\/graphql<\/pre><p>Before connecting the API to a public website or app, configure roles and permissions. Directus keeps collection access controlled, so you need to define which users or applications can read, create, update, or delete content. For a public blog, you can allow read-only access to published posts while keeping drafts, user data, and admin-only fields private.<\/p><p>Once permissions are set, connect your frontend to the Directus API. A website can fetch content from Directus and render it with a frontend framework, static site generator, or custom application. For example, your frontend can request published posts from the REST API and display them as blog articles, documentation pages, portfolio entries, or product listings.<\/p><p>This setup turns Directus into both a headless CMS and a data API. Editors get a clean interface for managing content, while developers get structured REST and GraphQL endpoints backed by the same database.<\/p><h2 class=\"wp-block-heading\" id=\"h-when-should-you-use-directus-with-docker\">When should you use Directus with Docker?<\/h2><p>Use Directus with Docker when you want a self-hosted headless CMS that turns database content into an API without building a custom admin panel or backend from scratch. This setup is especially useful when your project needs structured content, editor access, and REST or GraphQL endpoints from the same database.<\/p><p>Directus with Docker works well for:<\/p><ul class=\"wp-block-list\">\n<li><strong>Headless websites and apps<\/strong> &ndash; manage content in Directus Studio and deliver it to a frontend built with Next.js, Vue, React, Astro, or another framework.<\/li>\n\n\n\n<li><strong>Existing database projects<\/strong> &ndash; connect Directus to a SQL database and give teams a visual interface for managing records.<\/li>\n\n\n\n<li><strong>Internal tools<\/strong> &ndash; create admin panels for business data, customer records, inventory, directories, or operational workflows.<\/li>\n\n\n\n<li><strong>Content APIs<\/strong> &ndash; expose selected collections through REST or GraphQL without manually coding each endpoint.<\/li>\n\n\n\n<li><strong>Prototype projects<\/strong> &ndash; build a working CMS and API layer quickly before investing in a custom backend.<\/li>\n\n\n\n<li><strong>Self-hosted CMS setups<\/strong> &ndash; keep control over hosting, database access, permissions, backups, and infrastructure.<\/li>\n<\/ul><p>Directus is not the best fit for every project. A traditional CMS may be simpler if you only need a basic website with built-in themes and page editing. A custom backend may be better if your application requires complex business logic, highly specific workflows, or API behavior beyond database-driven content management.<\/p><p>For most database-backed websites and applications, Directus with Docker gives you a practical middle ground: developers keep control over the data model and infrastructure, while editors get a clean CMS interface for managing content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Directus with Docker lets you run a self-hosted headless CMS that turns a SQL database into a content management system and an auto-generated API. You can install Directus manually with Docker Compose or deploy it faster using Hostinger&rsquo;s Directus Docker template. To set up Directus, you&rsquo;ll need a server or local machine with Docker, Docker [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/uk\/tutorials\/how-to-install-directus-docker\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":342,"featured_media":132891,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to install Directus with Docker","rank_math_description":"Learn how to install Directus with Docker, deploy it with Hostinger's template, and use it as a headless CMS and data API.","rank_math_focus_keyword":"directus docker","footnotes":""},"categories":[22640],"tags":[],"class_list":["post-132890","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-directus-docker","default":1},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-UK","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-directus-docker","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-directus-docker","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/132890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/users\/342"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/comments?post=132890"}],"version-history":[{"count":0,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/posts\/132890\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media\/132891"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/media?parent=132890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/categories?post=132890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/uk\/tutorials\/wp-json\/wp\/v2\/tags?post=132890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}