You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Running Umbraco on docker locally using docker compose"
3
+
---
4
+
5
+
# Running Umbraco in Docker using Docker Compose
6
+
7
+
To aid in developing Umbraco with additional services, the templates can provide the requisite files to run Umbraco with an SQL Server database in Docker. This setup is designed to be used for local development, and not for production.
8
+
9
+
## Prerequisites
10
+
11
+
Before you can run Umbraco in Docker, you need to have the following installed:
12
+
* Version 14.3.0 or higher of the Umbraco Templates
13
+
* Docker Desktop
14
+
15
+
## Installing
16
+
17
+
Installing Umbraco with the Docker file and Docker Compose file is a two-step process.
18
+
19
+
1. Create a folder to hold your project and enter that folder.
20
+
21
+
```bash
22
+
mkdir MyDockerProject
23
+
cd MyDockerProject
24
+
```
25
+
2. Create your Umbraco project using the Umbraco Templates, and remember to use the `--add-docker` flag to include the Docker files.
26
+
27
+
28
+
Conventionally this is named the same as the folder, but it is not a requirement.
29
+
30
+
```bash
31
+
dotnet new umbraco -n MyDockerProject --add-docker
32
+
```
33
+
34
+
Now we need to add some additional files to make docker compose work. We can do this using the umbraco-compose template, passing the project name we specified earlier to the -P parameter:
35
+
36
+
```bash
37
+
dotnet new umbraco-compose -P "MyDockerProject"
38
+
```
39
+
40
+
The `-P` flag is required to specify the correct paths in the docker-compose file. The project is now ready to run with docker compose.
41
+
42
+
The final folder structure looks like this:
43
+
44
+
* MyDockerProject
45
+
* MyDockerProject
46
+
* Typical project files
47
+
* DockerFile
48
+
*`.dockerignore`
49
+
*`.env`
50
+
* Database
51
+
* DockerFile
52
+
*`healthcheck.sh`
53
+
*`setup.sql`
54
+
*`startup.sh`
55
+
*`docker-compose.yml`
56
+
57
+
The project now includes docker files for both Umbraco and the SQL server database.
58
+
59
+
It also includes additional scripts to launch and configure the database and a `.env` file with the database password.
60
+
61
+
## Running
62
+
63
+
To run the project use the `docker compose up` command in the root of the project files where the `docker-compose.yml` is.
64
+
65
+
This command will build both the Umbraco and SQL Server images and launch them in the correct order. When the site is booted, access it in your browser on `http://localhost:44372/`.
66
+
67
+
### Useful commands
68
+
69
+
There are some useful commands you can use to manage the docker containers:
70
+
71
+
*`docker compose down --volumes`: Delete your containers and the volumes they use. This is useful if you want to start from scratch.
72
+
73
+
{% hint style="warning" %}
74
+
Be careful with this command, as it deletes your database and all data in it.
75
+
{% endhint %}
76
+
77
+
*`docker compose up --build`: Rebuild the images and start the containers. This is useful if you have made changes to the project and want to see them reflected on the running site.
78
+
*`docker compose watch`: Start the containers and watch the default models folder. This means that if the project uses a source-code models builder the images are automatically rebuilt and restarts when you change the models.
79
+
80
+
## Details
81
+
82
+
The docker compose file uses bind mounts for the following folders:
83
+
84
+
*`/wwwroot/media`
85
+
*`/wwwroot/scripts`
86
+
*`/wwwroot/css`
87
+
*`/Views`
88
+
*`/models`
89
+
90
+
This is not meant to be used in production.
91
+
92
+
For local development, however, this means that the files necessary for development are available from outside the container in your IDE. This allows development even though the project is running in docker.
93
+
94
+
## Template options
95
+
96
+
The `umbraco-compose` template has a few options that can be used to customize the setup:
97
+
98
+
*`-P` or `--project-name`: The name of the project. This is required and used to set the correct paths in the docker-compose file.
99
+
*`-dbpw` or `--DatabasePasswor`: Used to specify the database password. This is stored in the `.env` file and defaults to: `Password1234`.
100
+
*`-p` or `--Port`: Used to specify the port the site will run on. Defaults to `44372`.
0 commit comments