Skip to main content

Quickstart using Docker

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 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 Clipboard

2. Change to the newly created project directory

cd my-medusa-starter
Copy to Clipboard

3. Rename the environment variables(.env) file

mv .env.template .env
Copy 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 Clipboard

If you get the error

Copy to Clipboard
, change the ports used for PostgreSQL in
Copy to Clipboard
to something like this:

  postgres:
ports:
- "5433:5433"
Copy 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

Copy to Clipboard
.

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

curl -X GET localhost:9000/store/products | python -m json.tool
Copy to Clipboard

This command uses Python to format the result of the request better in your command line. If you don't want to use Python you can simply send a request without the formatting:

curl localhost:9000/store/products
Copy 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.

What's Next

  • 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.