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
This page outlines what properties of the [Compose specification](https://docs.docker.com/compose/compose-file/) Defang supports when writing a `compose.yaml` file.
10
-
For a more general overview of how Defang works with Compose, please see our [Compose](/docs/concepts/compose) page.
9
+
## Required Compose File
10
+
Here is a basic `compose.yaml` file that contains all the required properties for deployment in Defang.
11
11
12
-
### Supported Compose Properties
13
-
|Property | Details
14
-
|-|-
15
-
|`image`|
12
+
```yaml
13
+
services:
14
+
service-example:
15
+
restart: unless-stopped # specify a restart mode
16
+
image: nginx:latest # specify an image (or a build, as shown below)
17
+
# build:
18
+
# context: .
19
+
# dockerfile: Dockerfile
20
+
ports:
21
+
- "8080:80"# specify ports to expose
22
+
23
+
```
16
24
17
-
### Optional Compose Properties
18
-
|Property | Details
19
-
|-|-
20
-
|`ports` | If left unspecified, a random port will be chosen.
21
-
|`memory` | If left unspecified, will resort to default.
22
-
|`environment`|
25
+
## Compose Service Properties
26
+
Here are a list of service-level properties of the [Compose specification](https://docs.docker.com/compose/compose-file/) that Defang supports when writing a `compose.yaml` file.
23
27
24
-
### Depreciated Compose Properties
25
-
|Property | Details
26
-
|-|-
27
-
|`version` | This top-level element is no longer needed in the Compose file. Instead, Defang uses the most recent schema supported for parsing the file.
28
+
:::tip
29
+
Service-level means inside your `service`. A service-level property called `build` would look like:
30
+
```yaml
31
+
service:
32
+
build: ...
33
+
```
28
34
29
-
### Unsupported Compose Properties
30
-
|Property | Details
31
-
|-|-
32
-
|`volume` | Volume mounts are not currently supported by Defang, but will not break the file if included.
35
+
Note that in your Compose file, you will need a top-level property called `services` to contain all of your services. For example:
36
+
```yaml
37
+
services:
38
+
service:
39
+
build: ...
40
+
another-service:
41
+
build: ...
42
+
```
43
+
:::
33
44
45
+
### `build`
46
+
(Required, unless `image` is defined)
47
+
48
+
The build configuration.
49
+
50
+
```yaml
51
+
build:
52
+
context: .
53
+
dockerfile: ./Dockerfile
54
+
```
55
+
56
+
### `command`
57
+
(Optional)
58
+
59
+
The command which will be run to start your service. If left out, the command from the docker image will be used.
60
+
61
+
```yaml
62
+
command: nginx -g 'daemon off;'
63
+
```
64
+
65
+
### `environment`
66
+
(Optional)
67
+
68
+
The environment variables to set.
69
+
70
+
```yaml
71
+
environment:
72
+
MYSQL_ROOT_PASSWORD: example
73
+
```
74
+
75
+
### `image`
76
+
(Required, unless `build` is defined)
77
+
78
+
The image to run.
79
+
80
+
```yaml
81
+
image: nginx:latest
82
+
```
83
+
84
+
### `ports`
85
+
(Optional, but required if you want to access the service from outside the container)
86
+
87
+
The ports to expose. Can be formatted as `"published:target"`.
88
+
89
+
```yaml
90
+
ports:
91
+
- "8080:80"
92
+
```
93
+
94
+
Alternatively, you can use this notation:
95
+
```yaml
96
+
ports:
97
+
- target: 80
98
+
published: 8080
99
+
mode: ingress
100
+
```
101
+
102
+
:::info
103
+
Defang ignores `published` ports in production. As such, it is common to make `target` and `published` ports the same when using Defang. However, it can be useful to include a `published` port for local development, such as Docker.
104
+
:::
105
+
106
+
### `restart`
107
+
(Required)
108
+
109
+
The restart mode for a container.
110
+
111
+
```yaml
112
+
restart: unless-stopped
113
+
```
114
+
115
+
### `version`
116
+
(Deprecated)
117
+
118
+
The version of the Compose file format being used. This feature is no longer supported and will be ignored by Defang.
119
+
120
+
### `volumes`
121
+
(Unsupported)
122
+
123
+
The volume for a container. This feature is not currently supported by Defang.
34
124
35
125
36
126
### Configuration
37
-
You can define sensitive environment variables/configuration for Defang by writing out the variable name and leaving it in as a blank or `null` value in the Compose file. See our [Configuration](/docs/concepts/configuration) page for more.
127
+
You can define sensitive environment variables/configuration for Defang by writing out the variable name and leaving it in as a blank or `null` value in the Compose file. See our [Configuration](/docs/concepts/configuration) page for more.
0 commit comments