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
Copy file name to clipboardExpand all lines: 15/umbraco-cms/fundamentals/setup/install/running-umbraco-on-docker-locally.md
+96-31Lines changed: 96 additions & 31 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,71 +4,136 @@ description: "Running Umbraco on docker locally using docker compose"
4
4
5
5
# Running Umbraco in Docker using Docker Compose
6
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.
7
+
This article shows how to run Umbraco locally in Docker using Docker Compose. You can use either SQL Server or SQLite for development.
8
+
9
+
{% hint style="info" %}
10
+
This setup is intended for local development only. It is not recommended for production environments.
11
+
{% endhint %}
8
12
9
13
## Prerequisites
10
14
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
15
+
Before you can run Umbraco in Docker, make sure the following are installed:
16
+
17
+
* .NET SDK with Umbraco Templates v15 or higher
13
18
* Docker Desktop
14
19
15
20
## Installing
16
21
17
-
Installing Umbraco with the Docker file and Docker Compose file is a two-step process.
22
+
To install Umbraco using the provided Dockerfile and Docker Compose setup, follow these steps:
23
+
24
+
### Option 1: Using SQL Server
18
25
19
-
1. Create a folder to hold your project and enter that folder.
26
+
1. Create a folder and navigate into it:
20
27
21
28
```bash
22
29
mkdir MyDockerProject
23
30
cd MyDockerProject
24
31
```
25
-
2. Create your Umbraco project using the Umbraco Templates, and remember to use the `--add-docker` flag to include the Docker files.
26
32
27
-
28
-
Conventionally this is named the same as the folder, but it is not a requirement.
33
+
2. Create a new Umbraco project with Docker support:
29
34
30
35
```bash
31
36
dotnet new umbraco -n MyDockerProject --add-docker
32
37
```
33
38
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:
39
+
3. Add Docker Compose files:
35
40
36
41
```bash
37
42
dotnet new umbraco-compose -P "MyDockerProject"
38
43
```
39
44
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.
45
+
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
46
42
-
The final folder structure looks like this:
47
+
The folder structure should now look like this:
43
48
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`
49
+
MyDockerProject/
50
+
├── Database/
51
+
│├── Dockerfile
52
+
||── healthcheck.sh
53
+
│├── setup.sql
54
+
│ ├── startup.sh
55
+
├── MyDockerProject/
56
+
│├── Your project files
57
+
│├── Dockerfile
58
+
||── .dockerignore
59
+
├── .env
60
+
├── docker-compose.yml
56
61
57
62
The project now includes docker files for both Umbraco and the SQL server database.
58
63
59
64
It also includes additional scripts to launch and configure the database and a `.env` file with the database password.
60
65
61
-
## Running
66
+
4. Run the following command from the root folder (where `docker-compose.yml` is located):
67
+
68
+
```bash
69
+
docker compose up
70
+
```
71
+
72
+
5. Access the site at `http://localhost:44372`.
73
+
74
+
### Option 2: Using SQLite
75
+
76
+
1. Create a new folder and navigate into it:
77
+
78
+
```bash
79
+
mkdir MyDockerSqliteProject
80
+
cd MyDockerSqliteProject
81
+
```
62
82
63
-
To run the project use the `docker compose up` command in the root of the project files where the `docker-compose.yml` is.
To speed up the build process, add a `.dockerignore` file to exclude unnecessary folders like `.git`, `bin`, and `obj`.
116
+
{% endhint %}
117
+
118
+
4. Build the container:
119
+
120
+
```bash
121
+
docker build -t umbraco-sqlite .
122
+
```
123
+
124
+
5. Run the container:
125
+
126
+
```bash
127
+
docker run -p 8080:8080 umbraco-sqlite
128
+
```
64
129
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/`.
130
+
6. Access the site at `http://localhost:8080`.
66
131
67
-
###Useful commands
132
+
## Useful Commands
68
133
69
134
There are some useful commands you can use to manage the docker containers:
70
135
71
-
*`docker compose down --volumes`: Delete your containers and the volumes they use. This is useful if you want to start from scratch.
136
+
*`docker compose down --volumes`: Deletes containers and the volumes they use. This is useful if you want to start from scratch.
72
137
73
138
{% hint style="warning" %}
74
139
Be careful with this command, as it deletes your database and all data in it.
@@ -77,7 +142,7 @@ Be careful with this command, as it deletes your database and all data in it.
77
142
*`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
143
*`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
144
80
-
## Details
145
+
## Bind Mounts (SQL Server setup)
81
146
82
147
The docker compose file uses bind mounts for the following folders:
83
148
@@ -91,9 +156,9 @@ This is not meant to be used in production.
91
156
92
157
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
158
94
-
## Template options
159
+
## Template Options (SQL Server only)
95
160
96
-
The `umbraco-compose` template has a few options that can be used to customize the setup:
161
+
The `umbraco-compose` template supports:
97
162
98
163
*`-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
164
*`-dbpw` or `--DatabasePassword`: Used to specify the database password. This is stored in the `.env` file and defaults to: `Password1234`.
0 commit comments