Home > Net >  Does docker's Dockerfile "From" download image?
Does docker's Dockerfile "From" download image?

Time:04-10

I followed this article to build multi domain websites
https://carlosvin.github.io/langs/en/posts/reverse-proxy-multidomain-docker/
This is a basic test, very simple. Only three files.

Edit
C:\Windows\System32\drivers\etc\hosts

127.0.0.1       a.local  
127.0.0.1       b.local  

C:\web\multidomain\docker-compose.yml

a:
  build: a
  environment:
    VIRTUAL_HOST: a.local
  restart: always

b:
  build: b
  environment:
    VIRTUAL_HOST:  b.local
  restart: always

nginx-proxy:
  image: jwilder/nginx-proxy
  ports:
    - "80:80"
    - "443:443"
  volumes:
    - /var/run/docker.sock:/tmp/docker.sock:ro

  restart: always
  privileged: true

C:\web\multidomain\a\Dockerfile

FROM httpd:2.4
RUN echo "<html><body><h1>A</h1>App A works!</body></html>" > /usr/local/apache2/htdocs/index.html

C:\web\multidomain\b\Dockerfile

FROM httpd:2.4
RUN echo "<html><body><h1>B</h1>App B works!</body></html>" > /usr/local/apache2/htdocs/index.html

That's all the folders and files. Then:

C:\web\multidomain> docker-compose up -d

It really works. Very very simple.

But my question is: There is a line "FROM httpd:2.4". As far as I know, this will download image and use it, isn't it? It should appear in my docker UI > Images section.But my docker no image called httpd:2.4.

If no image called httpd:2.4, Why does it still work?

x x x x x x

PS C:\Docker\MultiDomainBasic> docker image ls
REPOSITORY                TAG         IMAGE ID       CREATED          SIZE
multidomainbasic_a        latest      fb826b8c2db3   44 seconds ago   144MB
multidomainbasic_b        latest      23b08c2f23ff   45 seconds ago   144MB
sail-8.1/app              latest      4451e0a34f0f   47 hours ago     1.09GB
wordpress                 php7.4      744143078625   2 days ago       605MB
memcached                 alpine      bcea36e93e26   4 days ago       8.21MB
nginx                     alpine      51696c87e77e   4 days ago       23.4MB
jwilder/nginx-proxy       alpine      dfb8bfd11460   5 days ago       42.3MB
mysql                     8.0         667ee8fb158e   10 days ago      521MB
php                       8.1.4-fpm   8c08d993542f   11 days ago      449MB
mailhog/mailhog           latest      4de68494cd0d   20 months ago    392MB

Maybe the httpd image is inside multidomainbasic_a, and multidomainbasic_b ?? It is wrapped ?

CodePudding user response:

The Dockerfile defines how your new image is created. You aren't running the httpd image, you are running two different images that extended the httpd image:

multidomainbasic_a        latest      fb826b8c2db3   44 seconds ago   144MB
multidomainbasic_b        latest      23b08c2f23ff   45 seconds ago   144MB

The layers from the httpd image will be found in each of those, with one additional layer created from the RUN step in your Dockerfile.

  • Related