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: src/content/blog/customizing-ddev-local-images-with-a-custom-dockerfile.md
+12-12Lines changed: 12 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,38 +1,38 @@
1
1
---
2
2
title: "Customizing DDEV images with a custom Dockerfile"
3
3
pubDate: 2020-04-07
4
-
modifiedDate: 2023-02-21
5
-
modifiedComment: Prepended `.ddev/web-build/` to the `mailhog.conf` example, as the `ADD` directive must be project-root relative.
6
-
summary: How you can use a custom Dockerfile to tailor DDEV’s images, complete with examples.
4
+
modifiedDate: 2024-12-31
5
+
modifiedComment: Updated obsolete content.
6
+
summary: How to use a custom Dockerfile to tailor DDEV’s images, complete with examples.
7
7
author: Randy Fay
8
8
featureImage:
9
-
src: /img/blog/2020/04/d8composer.png
9
+
src: /img/blog/2020/04/Dockerfile.cron.png
10
10
alt: Tightly-cropped screenshot of a Dockerfile in an IDE.
11
11
shadow: true
12
12
categories:
13
13
- Guides
14
14
---
15
15
16
-
Did you know that you can customize [DDEV](https://github.com/ddev/ddev) Docker images with some very simple changes?
16
+
Did you know that you can customize [DDEV](https://github.com/ddev/ddev) Docker images with some very simple changes? See the [full docs](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/) but we'll give some examples here.
17
17
18
18
There are two major ways to customize your DDEV web image:
19
19
20
-
1. Add a Debian package into the image with `webimage_extra_packages` ([docs](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-debian-packages-with-webimage%5Fextra%5Fpackages-and-dbimage%5Fextra%5Fpackages)).
20
+
1. Add a Debian package into the image with `webimage_extra_packages` ([docs](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-debian-packages-with-webimage_extra_packages-and-dbimage_extra_packages)).
21
21
2. Add an “extension” Dockerfile with free-form instructions for adding onto the container ([docs](https://ddev.readthedocs.io/en/stable/users/extend/customizing-images/#adding-extra-dockerfiles-for-webimage-and-dbimage)).
22
22
23
23
You can use these together (add packages with `webimage_extra_packages` and also do more sophisticated things in a Dockerfile).
24
24
25
25
### `webimage_extra_packages` in `config.yaml`
26
26
27
-
The simplest thing to do is add new Debian packages. For example, add to the `.ddev/config.yaml`: `webimage_extra_packages: [redis-tools, php8.1-yaml]`, and the “redis-tools” and “php8.1-yaml” packages will be installed in the web container. This little addition to the container happens once, and doesn’t slow down your `ddev start` after that.
27
+
The simplest thing to do is add new Debian packages. For example, add to the `.ddev/config.yaml`: `webimage_extra_packages: [redis-tools, php${DDEV_PHP_VERSION}-yaml]`, and the `redis-tools` and `php${DDEV_PHP_VERSION}-yaml` (with your PHP version) packages will be installed in the web container. This little addition to the container happens once, and doesn’t slow down your `ddev start` after that.
28
28
29
29
### Simple npm install with custom Dockerfile
30
30
31
31
Sometimes, though, people need to do things that are more specific than changing Debian apt packages. For example, you might want to override a configuration file with a replacement, or you might want to use npm to install something that is not managed with Debian’s package system.
32
32
33
-
This kind of change can be done by creating a `.ddev/web-build/Dockerfile` (start by copying `.ddev/web-build/Dockerfile.example`).
33
+
This kind of change can be done by creating a `.ddev/web-build/Dockerfile.*` (we'll use `Dockerfile.gulp-cli). Start by copying `.ddev/web-build/Dockerfile.example`.
34
34
35
-
So, for example, if you have a `.ddev/web-build/Dockerfile` with these contents:
35
+
So, for example, if you have a `.ddev/web-build/Dockerfile.gulp-cli` with these contents:
36
36
37
37
```docker
38
38
RUN npm install --global gulp-cli
@@ -51,13 +51,13 @@ If you want to add files or override configuration files, it’s easy enough to
But you could use this same technique for so many things. Do you need to completely override the /etc/php/8.1/fpm/php-fpm.conf file? Do it. Do you need to completely revamp the entire nginx configuration directory? Now you can do it. You can also add scripts into the container or even Linux binaries. And you can check the whole thing into your project so that other members of your team automatically have it.
54
+
But you could use this same technique for so many things. Do you need to completely override the /etc/php/8.4/fpm/php-fpm.conf file? Do it. Do you need to completely revamp the entire nginx configuration directory? You can do it. You can also add scripts into the container or even Linux binaries. And you can check the whole thing into your project so that other members of your team automatically have it.
55
55
56
56
### pip3 installs
57
57
58
58
The Python world uses [pip3](https://pip.pypa.io/en/stable/) to install packages, and you can do that too.
59
59
60
-
This [Stack Overflow answer](https://stackoverflow.com/a/60683558/215713) goes into the details, but this Dockerfile should be a start:
60
+
This [Stack Overflow answer](https://stackoverflow.com/a/60683558/215713) goes into the details, but this Dockerfile.mycli should be a start:
@@ -80,4 +80,4 @@ RUN cp /etc/php/7.1/mods-available/mcrypt.ini /etc/php/${DDEV_PHP_VERSION}/mods-
80
80
81
81
## Join the conversation!
82
82
83
-
We’d love to hear about your recipes! Discuss them in our [Discord channel](/s/discord), create a new [DDEV Add-on](https://ddev.readthedocs.io/en/stable/users/extend/additional-services/), or tweet, or blog about them and give us a holler when you do. And we’re always happy to hear from you on any of our [support channels](https://ddev.readthedocs.io/en/stable/users/support/).
83
+
We’d love to hear about your recipes! Discuss them in our [Discord channel](/s/discord), create a new [DDEV Add-on](https://ddev.readthedocs.io/en/stable/users/extend/additional-services/), and let us know when you do, or blog about them and give us a holler when you do. And we’re always happy to hear from you on any of our [support channels](https://ddev.readthedocs.io/en/stable/users/support/).
0 commit comments