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 a SQL Server database in Docker.
8
+
This setup is designed to be used for local development, and not for production.
9
+
10
+
## Prerequisites
11
+
12
+
Before you can run Umbraco in Docker, you need to have the following installed:
13
+
* Version 14.3.0 or higher of the Umbraco Templates
14
+
* Docker Desktop
15
+
16
+
## Installing
17
+
18
+
Installing Umbraco with the Docker file and Docker Compose file is a two-step process.
19
+
20
+
First, create a folder to hold your project and enter that folder.
21
+
22
+
```bash
23
+
mkdir MyDockerProject
24
+
cd MyDockerProject
25
+
```
26
+
Next create your Umbraco project using the Umbraco Templates, and remember to use the `--add-docker` flag to include the Docker files.
27
+
Conventionally this is named the same as the folder, but is not a requirement.
28
+
29
+
```bash
30
+
dotnet new umbraco -n MyDockerProject --add-docker
31
+
```
32
+
33
+
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 wwe just specified to the `-P` parameter:
34
+
35
+
```bash
36
+
dotnet new umbraco-compose -P "MyDockerProject"
37
+
```
38
+
39
+
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.
40
+
41
+
The final folder structure looks like this:
42
+
43
+
* MyDockerProject
44
+
* MyDockerProject
45
+
* Typical project files
46
+
* DockerFile
47
+
* .dockerignore
48
+
* .env
49
+
* Database
50
+
* DockerFile
51
+
* healthcheck.sh
52
+
* setup.sql
53
+
* startup.sh
54
+
* docker-compose.yml
55
+
56
+
As you can see the project now includes docker files for both Umbraco itself and the SQL server database, as well as some additional scripts to launch and configure the database.
57
+
58
+
It also includes a .env file with the password for the database.
59
+
60
+
## Running
61
+
62
+
To run the project run the `docker compose up` command from the root of the project, same folder as `docker-compose.yml`.
63
+
64
+
This command will build both the Umbraco and Sql Server images and launch them in the correct order, after a while the site will have booted and you can navigate to it in your browser like nomral on `http://localhost:44372/`
65
+
66
+
### Useful commands
67
+
68
+
There is some useful commands you can use to manage the docker containers:
69
+
70
+
*`docker compose down --volumes` This will delete your containers AND the volumes they use, this is useful if you want to start from scratch.
71
+
72
+
{% hint style="warning" %}
73
+
This delete your database and all data in it, so be careful with this command.
74
+
{% endhint %}
75
+
76
+
*`docker compose up --build` This will rebuild the images and start the containers, this is useful if you have made changes to the project and want to see them reflected in the running site.
77
+
*`docker compose watch` This will start the containers and watch the default models folder, this means that if the project uses source code models builder the images automatically rebuilds and restarts when you change the models.
78
+
79
+
## Details
80
+
81
+
The docker compose file uses bind mounts for the following folders:
82
+
83
+
* /wwwroot/media
84
+
* /wwwroot/scripts
85
+
* /wwwroot/css
86
+
* /Views
87
+
* /models
88
+
89
+
This is bad for production, however, for local development this means that the files necessary for development are available from outside the container in your IDE allowing you to effectively develop even though the project is running in docker.
90
+
91
+
## Template options
92
+
93
+
The `umbraco-compose` template has a few options that can be used to customize the setup:
94
+
95
+
* -P or --project-name: The name of the project, this is required and used to set the correct paths in the docker-compose file.
96
+
* -dbpw or --DatabasePasswor: Used to specify the database password, this is stored in the .env file, defaults to: Password1234
97
+
* -p or --Port: Used to specify the port the site will run on, defaults to 44372
0 commit comments