Orchard Core Tutorials using Docker Running an Orchard Core CMS Website in a Docker container

Running an Orchard Core Website in a Docker Container

Orchard Core has Docker images on Docker Hub for both Linux and Windows if you find it convenient to spin up an Orchard Core CMS website using Docker on your development machine to test new features. I always have the latest development image on my MacBook Pro and use it often for testing and trying new features. If you’re new to Docker, the Orchard Core documentation on using Orchard Core with Docker may seem a bit sparse. Therefore, let's look at using Orchard Core with Docker on your development machine in much more detail. The tutorial assumes you have Docker Desktop installed so that you can work with Docker images and containers.

Running Orchard Core using Docker

The easiest way to jump in and start using Orchard Core with Docker is to issue the Docker run command to pull down the latest development image from Docker Hub and spin it up in a new container.

docker run --name oc -p 8080:80 orchardproject/orchardcore-cms-linux:dev

This command specifies the following:

  • The name of the container to be created and run: oc
  • Map Port 80 in the container to Port 8080 on my development machine
  • The name and tag of the image to use for the container: orchardproject/orchardcore-cms-linux:dev

When running this command, Docker will first look for the image locally. If Docker cannot find it or there is a newer version of the image on Docker Hub, it will download the image from Docker Hub. Docker will then create a new container, called oc, and start it.


Unable to find image 'orchardproject/orchardcore-cms-linux:dev' locally
dev: Pulling from orchardproject/orchardcore-cms-linux
d121f8d1c412: Pull complete
7b2d5a029506: Pull complete
778ad5bbc2d1: Pull complete
6de7a0eb2598: Pull complete
6d9bf7184ec4: Pull complete
834076497577: Pull complete
8e65d1ec0e85: Pull complete
Digest: sha256:139b11eb0c5568dd4f7b19ed110a54ebd03b1bdbc5422264a96e863e69978c20
Status: Downloaded newer image for orchardproject/orchardcore-cms-linux:dev
|INFO|Microsoft.Hosting.Lifetime|Now listening on: http://[::]:80
|INFO|Microsoft.Hosting.Lifetime|Application started. Press Ctrl+C to shut down.
|INFO|Microsoft.Hosting.Lifetime|Hosting environment: Production
|INFO|Microsoft.Hosting.Lifetime|Content root path: /app

You can now access the Orchard Core CMS website running in the Docker container from the browser at localhost:8080. Since this is your first time running the website, it should bring you to the Orchard Core CMS Setup Page.

http://localhost:8080

Orchard Core CMS Startup Page

Once you’re done playing with the new features, you can press CTRL+C in the terminal to stop the web server. Even though the web server is no longer running, the container is still running. You can list all running Docker containers and then stop the container by issuing the following commands.


docker ps
docker stop oc

You can come back later and list all Docker containers (both running and stopped) and re-start the Orchard Core container and web server in interactive mode with the following commands.


docker ps -all
docker start -i oc

|INFO|Microsoft.Hosting.Lifetime|Now listening on: http://[::]:80
|INFO|Microsoft.Hosting.Lifetime|Application started. Press Ctrl+C to shut down.
|INFO|Microsoft.Hosting.Lifetime|Hosting environment: Production
|INFO|Microsoft.Hosting.Lifetime|Content root path: /app

Once again, you can now access the Orchard Core website from the browser.

http://localhost:8080

Like before, once you’re finished running Orchard Core, you can press CTRL+C in the terminal to stop the web server and then issue the following command to stop the container.

docker stop oc

If you’re completely done using this container and wish to remove it, run the following command.

docker rm oc

Although the container has been removed, the Ochard Core Docker image is still on your machine. You can list all Docker images installed locally and optionally remove the Orchard Core Docker image.


docker image ls
docker image rm 358c

Above I am removing the Orchard Core Docker image by specifying the first 4 characters of its image id. Depending on when you read this tutorial, the Orchard Core development image id may be different. Specifying the first 4 digits of the image id saves me a few keystrokes from typing in the image name and tag as such:

docker image rm orchardproject/orchardcore-cms-linux:dev

You’re now essentially back at square 1, and can run through this Docker tutorial a second time if you wish.

Persisting the Orchard Core APP_Data Folder

When running Orchard Core in a Docker container you may want to persist the APP_Data folder used by Orchard Core in the container on your local machine. If so, you will want to mount a local folder (volume) on your development machine to the app/App_Data folder used by Orchard Core in the container. You can do so by changing the Docker run command to specify this new volume.

docker run --name oc -v c:/ocappdata:/app/App_Data -p 8080:80 orchardproject/orchardcore-cms-linux:dev

The command above mounts a local folder, called c:/ocappdata, to the /app/App_Data folder in the container. You need to create this local folder before issuing the Docker run command. Now when you run Orchard Core in the Docker container, the contents of the App_Data folder will be created and persisted on your development machine at c:/ocappdata rather than in the Docker container.