Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can Dockerfiles chain from other Dockerfiles?

Tags:

docker

I would like to chain Dockerfiles without using a registry, is this possible with the FROM statement?

For example, take two Dockerfiles:

Dockerfile
/some/other/dir/Dockerfile

How could the first Dockerfile chain from the second?

FROM /some/other/dir/Dockerfile

(the above is invalid but what I would like to do)

like image 999
James Avatar asked Oct 15 '25 07:10

James


1 Answers

You can chain the FROM directive, not directly, but by creating different images that contain the other one, like russian dolls.

Have a look at the Wordpress docker image at

https://hub.docker.com/_/wordpress/

If I look at one of the Dockerfiles, at

https://github.com/docker-library/wordpress/blob/b807f1285869a220a5f72b935901603e5bde8822/php5.6/apache/Dockerfile

I see

FROM php:5.6-apache

then again

if I look at

https://github.com/docker-library/php/blob/e573f8f7fda5d7378bae9c6a936a298b850c4076/5.6/apache/Dockerfile

I see

FROM debian:jessie

of course, you will have to create an image, then docker commit myimage1

see the doc

https://docs.docker.com/engine/reference/commandline/commit/

and then you can have a Dockerfile that begins with

FROM myimage1

and so on several times

like image 149
user2915097 Avatar answered Oct 17 '25 02:10

user2915097



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!