Create a Dockerfile for a CMS application
Describes how to create a Docker file for an Optimizely Content Management System (CMS) application.
Containerize an Optimizely Content Management System (CMS) 13 application so it deploys consistently across Linux and Windows hosts. This article walks through the Dockerfile, the .dockerignore file, and the commands to build and run the image.
Before you begin
- Docker Desktop installed on your machine.
- A buildable CMS 13 ASP.NET Core application. The project in this example is
episerversample. See Install a sample site. - A chosen container mode (Linux or Windows) in Docker Desktop.
If you are new to ASP.NET, follow the ASP.NET Get Started tutorial to initialize a project, or clone the ASP.NET Docker Sample.
Create a Dockerfile for the application
-
Create a Dockerfile in your project folder.
-
Add the following content to your Dockerfile for Linux or Windows containers. The tags are multi-arch: they pull Windows or Linux containers depending on the mode set in Docker Desktop for Windows. See Switch between Windows and Linux containers.
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build-env WORKDIR /app COPY *.csproj ./ RUN dotnet restore COPY . ./ RUN dotnet publish -c Release -o out FROM mcr.microsoft.com/dotnet/aspnet:10.0 WORKDIR /app COPY --from=build-env /app/out . EXPOSE 80 ENTRYPOINT ["dotnet", "episerversample.dll"] -
The Dockerfile assumes the application is
episerversample. Change theENTRYPOINTline to reference the DLL of your project. -
To minimize the build context, add a
.dockerignorefile to your project folder with the following contents:bin/ obj/
Build and run the Docker image
-
Open a command prompt and go to your project folder.
-
Build the Docker image:
docker build -t episerversample . -
Run the Docker image:
docker run -it -e "Urls=http://+:80" -p 8080:80 episerversample
Updated about 13 hours ago
