Docker Community Forums

Share and learn in the Docker community.

Best practices for using custom images in projects

I am using a custom PHP image in a project.
I have one multi-stage Dockerfile for the whole app, in which I’ve defined a parent PHP image, and two “children”, one for dev and another for tests, like this:

# /Dockerfile
FROM php:7.2-fpm AS php_parent
#...
FROM php_parent AS php_dev
#...
FROM php_parent AS php_test
#...
FROM nginx:1.14
#...

Then I use these different images in a docker-compose file.

The parent image should not change much over time, so I could push it to a repository.

But then, how should I use it?

Should I keep a separate Dockerfile for that parent image, then change the Dockerfile of the project, like this?

# /docker/php_parent/Dockerfile
FROM php:7.2-fpm AS php_parent
#...
# /Dockerfile
FROM my.registry/project/php_parent AS php_dev
#...
FROM my.registry/project/php_parent AS php_test
#...
FROM nginx:1.14
#...

Then of course, I would not be able to build the whole app in one Docker command.
I’d have to ensure the image is published and up to date, and the registry is accessible to all people working on the project, right?