Skip to main content

Quickstart using Docker: Medusa Server

In this document, you will learn how to make a container of Medusa's app on Docker. Docker is an open source platform for building, deploying, and managing containerized applications.

Prerequisites

Node.js

Medusa supports Node versions 14 and 16. You can check which version of Node you have by running the following command:

node -v
Copy to ClipboardCopy to Clipboard

You can install Node from the official website.

Docker Desktop

It is assumed that you have Docker installed on your system. You can install it from Docker's website.


Create Medusa Server with Docker

1. Clone Medusa's starter project from GitHub

git clone https://github.com/medusajs/medusa-starter-default.git my-medusa-starter
Copy to ClipboardCopy to Clipboard

2. Change to the newly created project directory

cd my-medusa-starter
Copy to ClipboardCopy to Clipboard

3. Rename the environment variables(.env) file

mv .env.template .env
Copy to ClipboardCopy to Clipboard

4. Start your server

Make sure the Docker Desktop app is running. Then, run the following command:

docker-compose up --build
Copy to ClipboardCopy to Clipboard

If you get the error ERROR: for postgres Cannot start service postgres: Ports are not available, change the ports used for PostgreSQL in docker-compose.yml to something like this:

  postgres:
ports:
- "5433:5433"
Copy to ClipboardCopy to Clipboard

Running the above command does the following:

  1. Build images for your Medusa project, a PostgreSQL database, and a Redis server
  2. Run migrations for your newly created database

Test Your Server

Once done, your server will be accessible at http://localhost:9000.

You can test out your server using tools like Postman or by sending a cURL request:

curl -X GET localhost:9000/store/products
Copy to ClipboardCopy to Clipboard

Additional steps

File Service Plugin

To upload product images to your Medusa server, you must install and configure one of the following file service plugins:

Server Configurations

It's important to configure your Medusa server properly and learn how environment variables are loaded.

You can learn more about configuring your server and loading environment variables in the Configure your Server documentation.


See Also

  • Install the Next.js or Gatsby storefronts to set up your ecommerce storefront quickly.
  • Install the Medusa Admin to supercharge your ecommerce experience with easy access to configurations and features.
  • Check out the API reference to learn more about available endpoints available on your Medusa server.
  • Install plugins for features like Payment, CMS, and Notifications, among other features.