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: cmd/ddev/cmd/ssh.go
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,6 @@ import (
5
5
"os/exec"
6
6
7
7
"github.com/ddev/ddev/pkg/ddevapp"
8
-
"github.com/ddev/ddev/pkg/nodeps"
9
8
"github.com/ddev/ddev/pkg/util"
10
9
"github.com/spf13/cobra"
11
10
)
@@ -21,6 +20,7 @@ var DdevSSHCmd = &cobra.Command{
21
20
Long: `Starts a shell session in the container for a service. Uses web service by default. To start a shell session for another service, run "ddev ssh --service <service>`,
22
21
Example: `ddev ssh
23
22
ddev ssh -s db
23
+
ddev ssh -s db -u root
24
24
ddev ssh <projectname>
25
25
ddev ssh -d /var/www/html`,
26
26
Args: cobra.MaximumNArgs(1),
@@ -36,14 +36,13 @@ ddev ssh -d /var/www/html`,
36
36
37
37
// Use Bash for our containers, sh for 3rd-party containers
Copy file name to clipboardExpand all lines: docs/content/users/configuration/hooks.md
+34-6Lines changed: 34 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,13 @@ DDEV currently supports these tasks:
42
42
43
43
### `exec`: Execute a shell command in a container (defaults to web container)
44
44
45
-
Value: string providing the command to run. Commands requiring user interaction are not supported. You can also add a “service” key to the command, specifying to run it on the `db` container or any other container you use.
45
+
Value: string providing the command to run. Commands requiring user interaction are not supported.
46
+
47
+
**Optional keys:**
48
+
49
+
* `service`: Specify which container to run the command in (defaults to `web`)
50
+
* `user`: Specify which user to run the command as (username or UID, defaults to container's default user)
51
+
* `exec_raw`: Array of command arguments for direct execution without shell interpretation (alternative to string command)
46
52
47
53
Example: _Use Drush to rebuild all caches and get a user login link after database import_.
48
54
@@ -76,15 +82,24 @@ hooks:
76
82
pre-import-db:
77
83
- exec: mysql -uroot -proot -e "CREATE DATABASE IF NOT EXISTS some_new_database;"
78
84
service: db
85
+
```
86
+
87
+
Example: _Execute a command as root user in the `db` container_.
79
88
89
+
```yaml
90
+
hooks:
91
+
post-start:
92
+
- exec: ls -la /root
93
+
service: db
94
+
user: root
80
95
```
81
96
82
97
Example: _Add the common `ll` alias into the `web` container’s `.bashrc` file_.
83
98
84
99
```yaml
85
100
hooks:
86
101
post-start:
87
-
- exec: sudo echo alias ll=\"ls -lhA\" >> ~/.bashrc
102
+
- exec: sudo echo alias ll=\"ls -lhA\" >> ~/.bashrc
88
103
```
89
104
90
105
!!!tip
@@ -95,8 +110,8 @@ Advanced usages may require running commands directly with explicit arguments. T
95
110
```yaml
96
111
hooks:
97
112
post-start:
98
-
- exec:
99
-
exec_raw: [ls, -lR, /var/www/html]
113
+
- exec:
114
+
exec_raw: [ls, -lR, /var/www/html]
100
115
```
101
116
102
117
### `exec-host`: Execute a shell command on the host system
@@ -113,6 +128,10 @@ hooks:
113
128
114
129
Value: string providing the Composer command to run.
115
130
131
+
**Optional keys:**
132
+
133
+
* `exec_raw`: Array of Composer command arguments (alternative to string command)
Copy file name to clipboardExpand all lines: docs/content/users/extend/custom-docker-services.md
+11-4Lines changed: 11 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -118,9 +118,11 @@ volumes:
118
118
- "../:/var/www/html:cached"
119
119
```
120
120
121
-
### Customizing ddev describe Output
121
+
### Customizing `ddev describe` Output
122
122
123
-
You can add custom descriptions that appear in `ddev describe` output using the `x-ddev` extension field. This is helpful for providing information about credentials, URLs, or usage instructions for your custom services.
123
+
You can use the `x-ddev` extension field in your `.ddev/docker-compose.*.yaml` configuration to customize the output of [`ddev describe`](../usage/commands.md#describe).
124
+
125
+
This feature is useful for showing credentials, URLs, or usage notes for custom services.
124
126
125
127
```yaml
126
128
services:
@@ -131,11 +133,12 @@ services:
131
133
com.ddev.site-name: ${DDEV_SITENAME}
132
134
com.ddev.approot: ${DDEV_APPROOT}
133
135
restart: "no"
134
-
ports:
136
+
expose:
135
137
- "15672"
136
138
environment:
137
139
- VIRTUAL_HOST=${DDEV_HOSTNAME}
138
140
- HTTP_EXPOSE=15672:15672
141
+
- HTTPS_EXPOSE=15673:15672
139
142
- RABBITMQ_DEFAULT_USER=rabbitmq
140
143
- RABBITMQ_DEFAULT_PASS=rabbitmq
141
144
x-ddev:
@@ -147,7 +150,11 @@ services:
147
150
describe-url-port: "extra help here"
148
151
```
149
152
150
-
The `x-ddev.describe-url-port` value appears in the URL/Port column when running `ddev describe` and the `x-ddev-describe-info` value appears in the `info` column, making it easy for team members to see important service information without digging through documentation and configuration files.
153
+
- `x-ddev.describe-url-port`: Appears in the `URL/PORT` column when running [`ddev describe`](../usage/commands.md#describe).
154
+
- `x-ddev.describe-info`: Appears in the `INFO` column, making it easy for team members to view relevant service details without checking config files.
155
+
156
+
!!!tip
157
+
See related `x-ddev.ssh-shell` configuration for [Changing `ddev ssh` Shell](../extend/in-container-configuration.md#changing-ddev-ssh-shell).
Copy file name to clipboardExpand all lines: docs/content/users/extend/in-container-configuration.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,6 +2,8 @@
2
2
3
3
Custom shell configuration (Bash or your preferred shell), your usual Git configuration, a Composer `auth.json` and more can be achieved within your containers.
4
4
5
+
## Using `homeadditions` to Customize In-Container Home Directory
6
+
5
7
Place all your dotfiles in your global`~/.ddev/homeadditions` or your project’s `.ddev/homeadditions` directory and DDEV will use these in your project’s `web` containers.
6
8
7
9
!!!tip "Ignore `.ddev/.homeadditions`!"
@@ -31,6 +33,36 @@ Usage examples:
31
33
alias ll="ls -lhA"
32
34
```
33
35
36
+
## Changing `ddev ssh` Shell
37
+
38
+
You can define a default shell for [`ddev ssh`](../usage/commands.md#ssh) using the `x-ddev` extension field in your `.ddev/docker-compose.*.yaml` configuration.
39
+
40
+
Use the `x-ddev.ssh-shell` key and make sure that shell (such as `zsh` or `bash`) is included in the container image so `ddev ssh` work correctly. The selected shell also appears in the [`ddev describe`](../usage/commands.md#describe) output (if it's not the default one).
41
+
42
+
Changing the default shell to `zsh` in the `web` and `db` containers:
43
+
44
+
```yaml
45
+
# .ddev/config.yaml
46
+
webimage_extra_packages: [zsh]
47
+
dbimage_extra_packages: [zsh]
48
+
```
49
+
50
+
```yaml
51
+
# .ddev/docker-compose.ssh-shell.yaml
52
+
services:
53
+
web:
54
+
x-ddev:
55
+
ssh-shell: zsh
56
+
db:
57
+
x-ddev:
58
+
ssh-shell: zsh
59
+
```
60
+
61
+
To change the shell for a custom service, add the `x-ddev.ssh-shell` field to that service's configuration and ensure the desired shell is [installed in the image](./customizing-images.md).
62
+
63
+
!!!tip
64
+
See related `x-ddev.describe-*` configuration for [Customizing `ddev describe` Output](../extend/custom-docker-services.md#customizing-ddev-describe-output).
65
+
34
66
## Using `NO_COLOR` Inside Containers
35
67
36
68
To set the `NO_COLOR` variable in all containers across all projects, define the `NO_COLOR` environment variable in your shell configuration file (e.g., `~/.bashrc` or `~/.zshrc`), outside of DDEV, for example:
0 commit comments