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
@@ -4,28 +4,105 @@ Docker compose is not intended for production use.
4
4
If you want to deploy a containerized DefectDojo to a production environment,
5
5
use the [Helm and Kubernetes](KUBERNETES.md) approach.
6
6
7
-
## Setup via Docker Compose
7
+
## Prerequisites
8
+
* Docker version
9
+
* Installing with docker-compose requires at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose.
10
+
* Proxies
11
+
* If you're behind a corporate proxy check https://docs.docker.com/network/proxy/ .
8
12
9
-
To start your DefectDojo instance on Docker Compose for the first time, just
10
-
run:
13
+
14
+
## Setup via Docker Compose - introduction
15
+
16
+
DefectDojo needs several docker images to run. Two of them depend on DefectDojo code:
17
+
18
+
* django service - defectdojo/defectdojo-django image
19
+
* nginx service - defectdojo/defectdojo-nginx image
20
+
21
+
The nginx image is build based on the django image.
22
+
23
+
Before running the application, it's advised to build local images to make sure that you'll be working on images consistent with your current code base.
24
+
When running the application without building images, the application will run based on:
25
+
* a previously locally built image if it exists in the docker cache
## Setup via Docker Compose - building and running the application
32
+
### Building images
33
+
34
+
To build images and put them in your local docker cache, run:
11
35
12
36
```zsh
13
-
. docker/aliases_release.sh
14
-
docker-compose up
37
+
docker-compose build
15
38
```
16
39
40
+
To build a single image, run:
41
+
42
+
```zsh
43
+
docker-compose build django
44
+
```
17
45
or
18
46
47
+
```
48
+
docker-compose build nginx
49
+
```
50
+
51
+
52
+
### Run with Docker compose in release mode
53
+
To run the application based on previously built image (or based on dockerhub images if none was locally built), run:
54
+
19
55
```zsh
20
-
docker-compose -f docker-compose_base.yml -f docker-compose_uwsgi-release.yml up
56
+
docker/setEnv.sh release
57
+
docker-compose up
21
58
```
22
59
23
-
This command will run the application based on images commited on dockerhub (or the last images built locally). If you need to be more up to date, see "Build images locally" below
60
+
This will run the application based on docker-compose.yml only.
61
+
62
+
In this setup, you need to rebuild django and/or nginx images after each code change and restart the containers.
63
+
64
+
65
+
### Run with Docker compose in development mode with hot-reloading
This will run the application based on merged configurations from docker-compose.yml and docker-compose.override.dev.yml.
76
+
77
+
* Volumes are mounted to synchronize between the host and the containers :
78
+
* static resources (nginx container)
79
+
* python code (uwsgi and celeryworker containers).
80
+
81
+
* The `--py-autoreload 1` parameter in entrypoint-uwsgi-dev.sh will make uwsgi handle python hot-reloading for the **uwsgi** container.
82
+
* Hot-reloading for the **celeryworker** container is not yet implemented. When working on deduplication for example, restart the celeryworker container with:
83
+
84
+
```
85
+
docker restart django-defectdojo_celeryworker_1
86
+
```
87
+
88
+
* The mysql port is forwarded to the host so that you can access your database from outside the container.
89
+
90
+
To update changes in static resources, served by nginx, just refresh the browser with ctrl + F5.
91
+
92
+
93
+
*Notes about volume permissions*
94
+
95
+
*The manual copy of settings.py is sometimes required once after cloning the repository, on linux hosts when the host files cannot be modified from within the django container. In that case that copy in entrypoint-uwsgi-dev.sh fails.*
96
+
97
+
*Another way to fix this is changing `USER 1001` in Dockerfile.django to match your user uid and then rebuild the images. Get your user id with*
24
98
25
-
**NOTE:** Installing with docker-compose requires the latest version of docker and docker-compose - at least docker 18.09.4 and docker-compose 1.24.0. See "Checking Docker versions" below for version errors during running docker-compose up.
99
+
```
100
+
id -u
101
+
```
26
102
103
+
### Access the application
27
104
Navigate to <http://localhost:8080> where you can log in with username admin.
28
-
To find out the admin user’s password, check the very beginning of the console
105
+
To find out the admin password, check the very beginning of the console
29
106
output of the initializer container, typically name 'django-defectdojo_initializer_1', or run the following:
30
107
31
108
```zsh
@@ -41,45 +118,38 @@ or:
41
118
docker logs django-defectdojo_initializer_1
42
119
```
43
120
44
-
If you ran DefectDojo with compose before and you want to prevent the
45
-
initializer container from running again, define an environment variable
46
-
DD_INITIALIZE=false to prevent re-initialization.
47
-
48
-
### Develop with Docker Compose
121
+
Beware that when re-running the application several times, there may be several occurrences of "Admin password". In that case you should use the last occurrence.
49
122
50
-
For developing the easiset way to make changes is to startup DefectDojo in debug by running:
51
-
52
-
```zsh
53
-
. docker/aliases_dev.sh
54
-
docker-compose up
55
-
```
123
+
### Disable the database initialization
124
+
The initializer container can be disabled by exporting: `export DD_INITIALIZE=false`.
56
125
57
-
or
126
+
This will ensure that the database remains unchanged when re-running the application, keeping your previous settings and admin password.
58
127
59
-
```zsh
60
-
docker-compose -f docker-compose_base.yml -f docker-compose_uwsgi-dev.yml up
61
-
```
128
+
### Versioning
129
+
In order to use a specific version when building the images and running the containers, set the environment with
130
+
* For the nginx image: `NGINX_VERSION=x.y.z`
131
+
* For the django image: `DJANGO_VERSION=x.y.z`
62
132
63
-
This starts the DefectDojo (uwsgi) container with manage.py and shares the local source directory so that changes to the code immediately restart the process.
133
+
Building will tag the images with "x.y.z", then you can run the application based on a specific tagged images.
64
134
65
-
Navigate to the container directly, <http://localhost:8000>
135
+
* Tagged images can be seen with:
66
136
67
-
The initializer container can be disabled by exporting: `export DD_INITIALIZE=false`
137
+
```
138
+
$ docker images
139
+
REPOSITORY TAG IMAGE ID CREATED SIZE
140
+
defectdojo/defectdojo-nginx 1.0.0 bc9c5f7bb4e5 About an hour ago 191MB
141
+
```
68
142
69
-
### Build Images Locally
143
+
* This will show on which tagged images the containers are running:
70
144
71
-
Build the docker containers locally for testing purposes.
145
+
```
146
+
$ docker ps
147
+
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
148
+
aedc404d6dee defectdojo/defectdojo-nginx:1.0.0 "/entrypoint-nginx.sh" 2 minutes ago Up 2 minutes 80/tcp, 0.0.0.0:8080->8080/tcp django-defectdojo_nginx_1
In this case, both docker (version 17.09.0-ce) and docker-compose (1.18.0) need to be updated.
129
236
130
-
Follow [Dockers' documentation](https://docs.docker.com/install/) for your OS to get the lastest version of Docker. For the docker command, most OSes have a built-in update mechanism like "apt upgrade".
237
+
Follow [Dockers' documentation](https://docs.docker.com/install/) for your OS to get the latest version of Docker. For the docker command, most OSes have a built-in update mechanism like "apt upgrade".
131
238
132
239
Docker Compose isn't packaged like Docker and you'll need to manually update an existing install if using Linux. For Linux, either follow the instructions in the [Docker Compose documentation](https://docs.docker.com/compose/install/) or use the shell script below. The script below will update docker-compose to the latest version automatically. You will need to make the script executable and have sudo privileges to upgrade docker-compose:
133
240
@@ -145,7 +252,7 @@ echo "Note: docker-compose version $VERSION will be downloaded from:"
0 commit comments