github.com/ddev/ddev@v1.23.2-0.20240519125000-d824ffe36ff3/docs/content/users/install/ddev-installation.md (about) 1 # DDEV Installation 2 3 Once you’ve [installed a Docker provider](docker-installation.md), you’re ready to install DDEV! 4 5 === "macOS" 6 7 ## macOS 8 9 ### Homebrew 10 11 [Homebrew](https://brew.sh/) is the easiest and most reliable way to install and upgrade DDEV: 12 13 ```bash 14 # Install DDEV 15 brew install ddev/ddev/ddev 16 17 # Initialize mkcert 18 mkcert -install 19 ``` 20 21 ### Install Script 22 23 The [install script](https://github.com/ddev/ddev/blob/master/scripts/install_ddev.sh) is another option. It downloads, verifies, and sets up the `ddev` binary: 24 25 ```bash 26 # Download and run the install script 27 curl -fsSL https://ddev.com/install.sh | bash 28 ``` 29 30 ??? "Need a specific version?" 31 Use the `-s` argument to specify a specific stable or prerelease version: 32 33 ```bash 34 # Download and run the script to install DDEV v1.21.4 35 curl -fsSL https://ddev.com/install.sh | bash -s v1.21.4 36 ``` 37 38 === "Linux" 39 40 ## Linux 41 42 ### Locally-trusted certificate with mkcert 43 44 Modern browsers require valid certificates, which mkcert can create. [Install mkcert](https://github.com/FiloSottile/mkcert#installation), and then run this: 45 46 ```bash 47 # Initialize mkcert 48 mkcert -install 49 ``` 50 51 Some versions of Firefox (Developer Edition, Flatpak) may need some [extra work](https://github.com/FiloSottile/mkcert/issues/370#issuecomment-1280377305), see also [this issue](https://github.com/ddev/ddev/issues/5415). 52 53 ### Debian/Ubuntu 54 55 DDEV’s Debian and RPM packages work with `apt` and `yum` repositories and most variants that use them, including Windows WSL2: 56 57 ```bash 58 # Add DDEV’s GPG key to your keyring 59 sudo sh -c 'echo ""' 60 sudo apt update && sudo apt install -y curl 61 sudo install -m 0755 -d /etc/apt/keyrings 62 curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null 63 sudo chmod a+r /etc/apt/keyrings/ddev.gpg 64 65 # Add DDEV releases to your package repository 66 sudo sh -c 'echo ""' 67 echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null 68 69 # Update package information and install DDEV 70 sudo sh -c 'echo ""' 71 sudo apt update && sudo apt install -y ddev 72 ``` 73 74 ??? "Need to remove a previously-installed variant?" 75 If you previously used DDEV’s [install script](#install-script), you can remove that version: 76 77 ``` 78 sudo rm -f /usr/local/bin/ddev /usr/local/bin/mkcert /usr/local/bin/*ddev_nfs_setup.sh 79 ``` 80 81 If you previously [installed DDEV with Homebrew](#homebrew), you can run `brew unlink ddev` to get rid of the Homebrew version. 82 83 ### Fedora, Red Hat, etc. 84 85 ```bash 86 # Add DDEV releases to your package repository 87 sudo sh -c 'echo ""' 88 echo '[ddev] 89 name=ddev 90 baseurl=https://pkg.ddev.com/yum/ 91 gpgcheck=0 92 enabled=1' | perl -p -e 's/^ +//' | sudo tee /etc/yum.repos.d/ddev.repo >/dev/null 93 94 # Install DDEV 95 sudo sh -c 'echo ""' 96 sudo dnf install --refresh ddev 97 ``` 98 99 Signed yum repository support will be added in the future. 100 101 ### Arch Linux 102 103 We maintain the [ddev-bin](https://aur.archlinux.org/packages/ddev-bin/) package in AUR for Arch-based systems including Arch Linux, EndeavourOS and Manjaro. Install with `yay` or your AUR tool of choice. 104 105 ```bash 106 # Install DDEV 107 yay -S ddev-bin 108 ``` 109 110 ### Homebrew (AMD64 only) 111 112 ```bash 113 # Install DDEV using Homebrew 114 brew install ddev/ddev/ddev 115 ``` 116 117 <!-- we’re using HTML here to customize the #install-script-linux anchor --> 118 <h3 id="install-script-linux">Install Script<a class="headerlink" href="#install-script-linux" title="Permanent link">¶</a></h3> 119 120 The [install script](https://github.com/ddev/ddev/blob/master/scripts/install_ddev.sh) is another option. It downloads, verifies, and sets up the `ddev` binary: 121 122 ```bash 123 # Download and run the install script 124 curl -fsSL https://ddev.com/install.sh | bash 125 ``` 126 127 ??? "Need a specific version?" 128 Use the `-s` argument to specify a specific stable or prerelease version: 129 130 ```bash 131 # Download and run the script to install DDEV v1.21.4 132 curl -fsSL https://ddev.com/install.sh | bash -s v1.21.4 133 ``` 134 135 === "Windows" 136 137 ## Windows 138 139 You can install DDEV on Windows three ways: 140 141 1. [Using WSL2 with Docker inside](#wsl2-docker-ce-inside-install-script) **Recommended, best performance, most reliable** 142 2. [Using WSL2 with Docker Desktop](#wsl2-docker-desktop-install-script) **May require license, less reliable** 143 3. [Installing directly on traditional Windows](#traditional-windows) with an installer **Legacy, slower performance** 144 145 **We strongly recommend using WSL2 for your Windows DDEV development environment.** While its Linux experience may be new for some Windows users, it’s worth the performance benefit and common experience of working with Ubuntu and Bash. 146 147 ### Important Considerations for WSL2 and DDEV 148 149 * You **must** use WSL2, not WSL version 1. 150 Use `wsl.exe -l -v` to see the versions of the distros you are using they should be v2. 151 * WSL2 is supported on Windows 10 and 11. 152 All Windows 10/11 editions, including Windows 10 Home support WSL2. 153 * WSL2 offers a faster, smoother experience. 154 It’s vastly more performant, and you’re less likely to have obscure Windows problems. 155 156 * Execute DDEV commands inside WSL2. 157 You’ll want to run DDEV commands inside Ubuntu, for example, and never on the Windows side in PowerShell or Git Bash. 158 * Projects should live under the home directory of the Linux filesystem. 159 WSL2’s Linux filesystem (e.g. `/home/<your_username>`) is much faster and has proper permissions, so keep your projects there and **not** in the slower Windows filesystem (`/mnt/c`). 160 * Custom hostnames are managed via the Windows hosts file, not within WSL2. 161 DDEV attempts to manage custom hostnames via the Windows-side hosts file—usually at `C:\Windows\system32\drivers\etc\hosts`—and it can only do this if it’s installed on the Windows side. (DDEV inside WSL2 uses `ddev.exe` on the Windows side as a proxy to update the Windows hosts file.) If `ddev.exe --version` shows the same version as `ddev --version` you’re all set up. Otherwise, install DDEV on Windows using `choco upgrade -y ddev` or by downloading and running the Windows installer. (The WSL2 scripts below install DDEV on the Windows side, taking care of that for you.) If you frequently run into Windows UAC Escalation, you can calm it down by running `gsudo.exe cache on` and `gsudo.exe config CacheMode auto`, see [gsudo docs](https://github.com/gerardog/gsudo#credentials-cache). 162 * WSL2 is not the same as Docker Desktop’s WSL2 engine. 163 Using WSL2 to install and run DDEV is not the same as using Docker Desktop’s WSL2 engine, which itself runs in WSL2, but can serve applications running in both traditional Windows and inside WSL2. 164 165 The WSL2 install process involves: 166 167 * Installing Chocolatey package manager (optional). 168 * One time initialization of mkcert. 169 * Installing WSL2 and installing a distro like Ubuntu. 170 * Optionally installing Docker Desktop for Windows and enabling WSL2 integration with the distro (if you're using the Docker Desktop approach). 171 * Installing DDEV inside your distro; this is normally done by running one of the two scripts below, but can be done manually step-by-step as well. 172 * Verify that your distro uses WSL version 2 with `wsl.exe -l -v`. 173 174 ### WSL2 + Docker CE Inside Install Script 175 176 This technique is our favorite, as it uses the most reliable WSL2 Docker provider (`docker-ce`), which is also free and open-source. 177 178 This script prepares your default WSL2 Ubuntu distro and doesn’t require Docker Desktop, and you can run the script multiple times without breaking anything. 179 180 In all cases: 181 182 1. Install WSL2 with an Ubuntu distro. 183 184 * Install WSL: 185 ``` 186 wsl --install 187 ``` 188 189 * Reboot if required. (Usually required.) 190 191 * Verify that you have an Ubuntu distro set as default by running `wsl.exe -l -v`. 192 If you have WSL2 but not an Ubuntu distro, install one by running `wsl.exe --install Ubuntu`. If this doesn’t work, see [manual installation](https://docs.microsoft.com/en-us/windows/wsl/install-manual) and [troubleshooting](https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#installation-issues). 193 194 * Verify that your Ubuntu default distro is WSL v2 using `wsl -l -v`. 195 196 2. In an administrative PowerShell run [this PowerShell script](https://raw.githubusercontent.com/ddev/ddev/master/scripts/install_ddev_wsl2_docker_inside.ps1) by executing: 197 198 ```powershell 199 Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; 200 iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ddev/ddev/master/scripts/install_ddev_wsl2_docker_inside.ps1')) 201 ``` 202 3. In *Windows Update Settings* → *Advanced Options* enable *Receive updates for other Microsoft products*. You may want to occasionally run `wsl.exe --update` as well. 203 204 Now you can use the "Ubuntu" terminal app or Windows Terminal to access your Ubuntu distro, which has DDEV and Docker working inside it. 205 206 ### WSL2 + Docker Desktop Install Script 207 208 WSL2 with Docker Desktop is a less-favored choice because Docker Desktop may be lightly supported, and has many features not required for use with DDEV that do not add particular value. It is also not free software (although smaller organizations can use it free of charge) and it is not open-source. 209 210 The script here prepares your default WSL2 Ubuntu distro for use with Docker Desktop, and you can run the script multiple times without breaking anything. 211 212 In all cases: 213 214 4. Install WSL2 with an Ubuntu distro. On a system without WSL2, run: 215 ```powershell 216 wsl --install 217 ``` 218 219 * Verify that you have an Ubuntu distro set as the default default with `wsl -l -v`. 220 221 * If you have WSL2 but not an Ubuntu distro, install one with `wsl --install Ubuntu`. 222 If that doesn't work for you, see [manual installation](https://docs.microsoft.com/en-us/windows/wsl/install-manual) and [troubleshooting](https://docs.microsoft.com/en-us/windows/wsl/troubleshooting#installation-issues). 223 224 If you prefer to use another Ubuntu distro, install it and set it as default. For example, `wsl --set-default Ubuntu-22.04`. 225 226 5. In *Windows Update Settings* → *Advanced Options* enable *Receive updates for other Microsoft products*. You may want to occasionally run `wsl.exe --update` as well. 227 228 6. Install Docker Desktop. If you already have Chocolatey, run `choco install -y docker-desktop`. Otherwise [download Docker Desktop from Docker](https://www.docker.com/products/docker-desktop/). 229 7. Start Docker Desktop. You should now be able to run `docker ps` in PowerShell or Git Bash. 230 8. In *Docker Desktop* → *Settings* → *Resources* → *WSL2 Integration*, verify that Docker Desktop is integrated with your distro. 231 9. In an administrative PowerShell run [this PowerShell script](https://raw.githubusercontent.com/ddev/ddev/master/scripts/install_ddev_wsl2_docker_desktop.ps1) by executing: 232 233 ```powershell 234 Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; 235 iex ((New-Object System.Net.WebClient).DownloadString('https://raw.githubusercontent.com/ddev/ddev/master/scripts/install_ddev_wsl2_docker_desktop.ps1')) 236 ``` 237 238 Now you can use the "Ubuntu" terminal app or Windows Terminal to access your Ubuntu distro, which has DDEV and Docker Desktop integrated with it. 239 240 ### WSL2/Docker Desktop Manual Installation 241 242 You can manually step through the process the install script attempts to automate: 243 244 1. Install [Chocolatey](https://chocolatey.org/install): 245 ```powershell 246 Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; 247 iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))` 248 ``` 249 2. In an administrative PowerShell, run `choco install -y ddev mkcert`. 250 3. In an administrative PowerShell, run `mkcert -install` and follow the prompt to install the Certificate Authority. 251 4. In an administrative PowerShell, run `$env:CAROOT="$(mkcert -CAROOT)"; setx CAROOT $env:CAROOT; If ($Env:WSLENV -notlike "*CAROOT/up:*") { $env:WSLENV="CAROOT/up:$env:WSLENV"; setx WSLENV $Env:WSLENV }`. This will set WSL2 to use the Certificate Authority installed on the Windows side. In some cases it takes a reboot to work correctly. 252 5. In administrative PowerShell, run `wsl --install`. This will install WSL2 and Ubuntu for you. Reboot when this is done. 253 6. **Docker Desktop for Windows:** If you already have the latest Docker Desktop, configure it in the General Settings to use the WSL2-based engine. Otherwise install the latest Docker Desktop for Windows and select the WSL2-based engine (not legacy Hyper-V) when installing. Install with Chocolatey by running `choco install docker-desktop`, or download the installer from [desktop.docker.com](https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe). Start Docker. It may prompt you to log out and log in again, or reboot. 254 7. Go to Docker Desktop’s *Settings* → *Resources* → *WSL integration* → *enable integration for your distro*. Now `docker` commands will be available from within your WSL2 distro. 255 8. Double-check in PowerShell: `wsl -l -v` should show three distros, and your Ubuntu should be the default. All three should be WSL version 2. 256 9. Double-check in Ubuntu (or your distro): `echo $CAROOT` should show something like `/mnt/c/Users/<you>/AppData/Local/mkcert` 257 10. Check that Docker is working inside Ubuntu (or your distro) by running `docker ps`. 258 11. Open the WSL2 terminal, for example `Ubuntu` from the Windows start menu. 259 12. Install DDEV: 260 261 ```bash 262 sudo apt update && sudo apt install -y curl 263 sudo install -m 0755 -d /etc/apt/keyrings 264 curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null 265 echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null 266 sudo apt update && sudo apt install -y ddev 267 ``` 268 269 13. In WSL2, run `mkcert -install`. 270 271 You have now installed DDEV on WSL2. If you’re using WSL2 for DDEV, remember to run all `ddev` commands inside the WSL2 distro. 272 273 !!!note "Path to certificates" 274 If you get the prompt `Installing to the system store is not yet supported on this Linux`, you may need to add `/usr/sbin` to the `$PATH` so that `/usr/sbin/update-ca-certificates` can be found. 275 276 ### Traditional Windows 277 278 If you must use traditional Windows, then Docker Desktop is your only choice of a Docker provider. DDEV is supported in this configuration but it's not as performant as the WSL2 options. 279 280 * We recommend using [Chocolatey](https://chocolatey.org/). Once installed, you can run `choco install ddev docker-desktop git` from an administrative shell. You can upgrade by running `ddev poweroff && choco upgrade ddev`. 281 * Each [DDEV release](https://github.com/ddev/ddev/releases) includes a Windows installer (`ddev_windows_installer.<version>.exe`). After running that, you can open a new Git Bash, PowerShell, or cmd.exe window and start using DDEV. 282 283 Most people interact with DDEV on Windows using Git Bash, part of the [Windows Git suite](https://git-scm.com/download/win). Although DDEV does work with cmd.exe and PowerShell, it's more at home in Bash. You can install Git Bash with Chocolatey by running `choco install -y git`. 284 285 !!!note "Windows Firefox Trusted CA" 286 287 The `mkcert -install` step on Windows isn’t enough for Firefox. 288 You need to add the created root certificate authority to the security configuration yourself: 289 290 * Run `mkcert -install` (you can use the shortcut from the Start Menu for that) 291 * Run `mkcert -CAROOT` to see the local folder used for the newly-created root certificate authority 292 * Open Firefox Preferences (`about:preferences#privacy`) 293 * Enter “certificates” into the search box on the top 294 * Click *View Certificates...* 295 * Select *Authorities* tab 296 * Click to *Import...* 297 * Navigate to the folder where your root certificate authority was stored 298 * Select the `rootCA.pem` file 299 * Click to *Open* 300 301 You should now see your CA under `mkcert development CA`. 302 303 === "Gitpod" 304 305 ## Gitpod 306 307 Choose any of the following methods to launch your project with [Gitpod](https://www.gitpod.io): 308 309 1. [Open any repository](https://www.gitpod.io/docs/getting-started) using Gitpod and run the following: 310 ```bash 311 # Add DDEV’s GPG key to your keyring 312 curl -fsSL https://pkg.ddev.com/apt/gpg.key | gpg --dearmor | sudo tee /etc/apt/keyrings/ddev.gpg > /dev/null 313 314 # Add DDEV releases to your package repository 315 echo "deb [signed-by=/etc/apt/keyrings/ddev.gpg] https://pkg.ddev.com/apt/ * *" | sudo tee /etc/apt/sources.list.d/ddev.list >/dev/null 316 317 318 # Update package information and install DDEV 319 sudo apt update && sudo apt install -y ddev 320 ``` 321 322 * You can install your web app there, or import a database. 323 * You may want to implement one of the `ddev pull` provider integrations to pull from a hosting provider or an upstream source. 324 2. Use the [ddev-gitpod-launcher](https://ddev.github.io/ddev-gitpod-launcher/) form to launch a repository. 325 You’ll provide a source repository and click a button to open a newly-established environment. You can specify a companion artifacts repository and automatically load `db.sql.gz` and `files.tgz` from it. (More details in the [repository’s README](https://github.com/ddev/ddev-gitpod-launcher/blob/main/README.md).) 326 3. Save the following link to your bookmark bar: <a href="javascript: if %28 %2Fbitbucket%2F.test %28 window.location.host %29 %20 %29 %20%7B%20paths%3Dwindow.location.pathname.split %28 %22%2F%22 %29 %3B%20repo%3D%5Bwindow.location.origin%2C%20paths%5B1%5D%2C%20paths%5B2%5D%5D.join %28 %22%2F%22 %29 %20%7D%3B%20if %28 %2Fgithub.com%7Cgitlab.com%2F.test %28 window.location.host %29 %29 %20%7Brepo%20%3D%20window.location.href%7D%3B%20if%20 %28 repo %29 %20%7Bwindow.location.href%20%3D%20%22https%3A%2F%2Fgitpod.io%2F%23DDEV_REPO%3D%22%20%2B%20encodeURIComponent %28 repo %29 %20%2B%20%22%2CDDEV_ARTIFACTS%3D%22%20%2B%20encodeURIComponent %28 repo %29 %20%2B%20%22-artifacts%2Fhttps%3A%2F%2Fgithub.com%2Fddev%2Fddev-gitpod-launcher%2F%22%7D%3B">Open in ddev-gitpod</a>. 327 It’s easiest to drag the link into your bookmarks. When you’re on a Git repository, click the bookmark to open it with DDEV in Gitpod. It does the same thing as the second option, but it works on non-Chrome browsers and you can use native browser keyboard shortcuts. 328 329 It can be complicated to get private databases and files into Gitpod, so in addition to the launchers, the [`git` provider example](https://github.com/ddev/ddev/blob/master/pkg/ddevapp/dotddev_assets/providers/git.yaml.example) demonstrates pulling a database and files without complex setup or permissions. This was created explicitly for Gitpod integration, because in Gitpod you typically already have access to private Git repositories, which are a fine place to put a starter database and files. Although [ddev-gitpod-launcher](https://ddev.github.io/ddev-gitpod-launcher/) and the web extension provide the capability, you may want to integrate a Git provider—or one of the [other providers](https://github.com/ddev/ddev/tree/master/pkg/ddevapp/dotddev_assets/providers)—for each project. 330 331 === "Codespaces" 332 333 ## GitHub Codespaces 334 335 You can use DDEV in remote [GitHub Codespaces](https://github.com/features/codespaces) without having to run Docker locally; you only need a browser and an internet connection. 336 337 Start by creating a `.devcontainer/devcontainer.json` file in your GitHub repository: 338 339 ```json 340 { 341 "image": "mcr.microsoft.com/devcontainers/universal:2", 342 "features": { 343 "ghcr.io/ddev/ddev/install-ddev:latest": {} 344 } 345 } 346 ``` 347 348 Launch your repository in Codespaces: 349 350 <div style="text-align:center;"><img style="max-width:400px;" src="./../../../images/codespaces-launch.png" alt="Screenshot of codespace create dialog in a repository on GitHub"></div> 351 352 <div style="text-align:center;"><img style="max-width:400px;" src="./../../../images/codespaces-setting-up.png" alt="Screenshot of codespace create dialog in a repository on GitHub"></div> 353 354 DDEV is now available within your new codespace instance: 355 356 <div style="text-align:center;"><img src="./../../../images/codespaces-hello-screen.png" alt=""></div> 357 358 Run `ddev config` to [start a new blank project](./../project.md) - or [install a CMS](./../quickstart.md). 359 360 Run `ddev start` if there is already a configured DDEV project in your repository. 361 362 **Troubleshooting**: 363 364 If there are errors after restarting a codespace, use `ddev restart` or `ddev poweroff`. 365 366 You can also use the commands 367 368 - "Codespaces: Rebuild container" 369 - "Codespaces: Full rebuild container" (Beware: database will be deleted) 370 371 via the [Visual Studio Code Command Palette](https://docs.github.com/en/enterprise-cloud@latest/codespaces/codespaces-reference/using-the-vs-code-command-palette-in-codespaces): 372 373 - <kbd>⌘</kbd> + <kbd>SHIFT</kbd> + <kbd>P</kbd> on a Mac 374 - <kbd>CTRL</kbd> + <kbd>SHIFT</kbd> + <kbd>P</kbd> on Windows/Linux 375 - from the Application Menu, click View > Command Palette (Firefox) 376 377 If you need DDEV-specific assistance or have further questions, see [support](./../support.md). 378 379 Your updated `devcontainer.json` file may differ depending on your project, but you should have `install-ddev` in the `features` section. 380 381 !!!note "Normal Linux installation also works" 382 You can also install DDEV as if it were on any normal [Linux installation](#linux). 383 384 ### Docker integration 385 386 DDEV in Codespaces relies on [`docker-in-docker`](https://github.com/devcontainers/features), which is installed by default when you use the image `"mcr.microsoft.com/devcontainers/universal:2"`. Please be aware: GitHub Codespaces and its Docker-integration (docker-in-docker) are relatively new. See [devcontainers/features](https://github.com/devcontainers/features) for general support and issues regarding Docker-support. 387 388 ### DDEV's router is not used 389 390 Since Codespaces handles all the routing, the internal DDEV router will not be used on Codespaces. Therefore config settings like [`web_extra_exposed_ports`](./../configuration/config.md#web_extra_exposed_ports) will have no effect. 391 392 You can expose ports via the `ports` setting, which is usually not recommended if you work locally due to port conflicts. But you can load these additional Docker compose files only when Codespaces is detected. See [Defining Additional Services](./../extend/custom-compose-files.md#docker-composeyaml-examples) for more information. 393 394 ``` 395 services: 396 web: 397 ports: 398 - "5174:5174" 399 ``` 400 401 ### Default environment variables 402 403 Codespace instances already provide some [default environment values](https://docs.github.com/en/codespaces/developing-in-codespaces/default-environment-variables-for-your-codespace). You can inherit and inject them in your `.ddev/config.yaml`: 404 405 ``` 406 web_environment: 407 - CODESPACES 408 - CODESPACE_NAME 409 - GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN 410 ``` 411 412 ### Advanced usage via devcontainer.json 413 414 A lot more customization is possible via the [`devcontainer.json`-configuration](https://containers.dev/implementors/json_reference/). You can install Visual Studio Code extensions by default or run commands automatically. 415 416 #### postCreateCommand 417 418 The [`postCreateCommand`](https://containers.dev/implementors/json_reference/) lets you run commands automatically when a new codespace is launched. DDEV commands are available here. 419 420 The event is triggered on: fresh creation, rebuilds and full rebuilds. `ddev poweroff` is used in this example to avoid errors on rebuilds since some Docker containers are kept. 421 422 You usually want to use a separate bash script to do this, as docker [might not yet be available when the command starts to run](https://github.com/devcontainers/features/issues/780). 423 424 ```json 425 { 426 "image": "mcr.microsoft.com/devcontainers/universal:2", 427 "features": { 428 "ghcr.io/ddev/ddev/install-ddev:latest": {} 429 }, 430 "portsAttributes": { 431 "3306": { 432 "label": "database" 433 }, 434 "8027": { 435 "label": "mailpit" 436 }, 437 "8080": { 438 "label": "web http" 439 }, 440 "8443": { 441 "label": "web https" 442 } 443 }, 444 "postCreateCommand": "chmod +x .devcontainer/setup_project.sh && .devcontainer/setup_project.sh" 445 } 446 ``` 447 448 ``` 449 #!/bin/bash 450 set -ex 451 452 wait_for_docker() { 453 while true; do 454 docker ps > /dev/null 2>&1 && break 455 sleep 1 456 done 457 echo "Docker is ready." 458 } 459 460 wait_for_docker 461 462 # download images beforehand, optional 463 ddev debug download-images 464 465 # avoid errors on rebuilds 466 ddev poweroff 467 468 # start ddev project automatically 469 ddev start -y 470 471 # further automated install / setup steps, e.g. 472 ddev composer install 473 ``` 474 475 To check for errors during the `postCreateCommand` action, use the command 476 477 - "Codespaces: View creation log” 478 479 via the [Visual Studio Code Command Palette](https://docs.github.com/en/enterprise-cloud@latest/codespaces/codespaces-reference/using-the-vs-code-command-palette-in-codespaces): 480 481 - <kbd>⌘</kbd> + <kbd>SHIFT</kbd> + <kbd>P</kbd> on a Mac 482 - <kbd>CTRL</kbd> + <kbd>SHIFT</kbd> + <kbd>P</kbd> on Windows/Linux 483 - from the Application Menu, click View > Command Palette (Firefox) 484 485 <div style="text-align:center;"><img src="./../../../images/codespaces-creation-log.png" alt=""></div> 486 487 === "Manual" 488 489 ## Manual 490 491 DDEV is a single executable, so installation on any OS is a matter of copying the `ddev` binary for your architecture into the appropriate system path on your machine. 492 493 * Download and extract the latest [DDEV release](https://github.com/ddev/ddev/releases) for your architecture. 494 * Move `ddev` to `/usr/local/bin` with `mv ddev /usr/local/bin/` (may require `sudo`), or another directory in your `$PATH` as preferred. 495 * Run `ddev` to test your installation. You should see DDEV’s command usage output. 496 * As a one-time initialization, run `mkcert -install`, which may require your `sudo` password. 497 498 If you don’t have `mkcert` installed, download the [latest release](https://github.com/FiloSottile/mkcert/releases) for your architecture and `sudo mv <downloaded_file> /usr/local/bin/mkcert && sudo chmod +x /usr/local/bin/mkcert`.