Richard
Richard

Reputation: 65550

How to see the source of a DockerHub container so I can adapt it?

I want to work on a GeoDjango application that will be easy for others to work on too. I would like to use Docker to package the application.

So, a very simple question.

I can see that there is an existing GeoDjango container on DockerHub: https://registry.hub.docker.com/u/jhonatasmartins/geodjango/

How can I view the Dockerfile for this container, so that I can use it as a basis for my own container?

Upvotes: 1

Views: 123

Answers (2)

Javier Cortejoso
Javier Cortejoso

Reputation: 9166

There are also times where doing a docker history <IMAGE_ID> could show you some tips about how the image was built. In fact, if the image was built using a Dockerfile will give you a clear image of the steps of the Dockerfile. For the ones committed from a containers you may not see some steps, but sometimes you can get some idea from there. For example for the image you said:

$ docker history jhonatasmartins/geodjango:latest
IMAGE               CREATED             CREATED BY                                      SIZE
0b7e890a4644        3 months ago        /bin/bash                                       112.2 MB
35174145916a        3 months ago        /bin/bash                                       449.9 MB
5506de2b643b        4 months ago        /bin/sh -c #(nop) CMD [/bin/bash]               0 B
22093c35d77b        4 months ago        /bin/sh -c apt-get update && apt-get dist-upg   6.558 MB
3680052c0f5c        4 months ago        /bin/sh -c sed -i 's/^#\s*\(deb.*universe\)$/   1.895 kB
e791be0477f2        4 months ago        /bin/sh -c rm -rf /var/lib/apt/lists/*          0 B
ccb62158e970        4 months ago        /bin/sh -c echo '#!/bin/sh' > /usr/sbin/polic   194.8 kB
d497ad3926c8        4 months ago        /bin/sh -c #(nop) ADD file:3996e886f2aa934dda   192.5 MB
511136ea3c5a        20 months ago                                                       0 B

Edit1: As jwodder recommended below add --no-trunc option to docker inspect to check the complete command of each layer. I won't put here the one for the example because it's too verbose, but definitely you will get more info using it.

Upvotes: 3

larsks
larsks

Reputation: 311870

There is (at the moment) no way to see the Dockerfile used to generate an image, unless the author has published the Dockerfile somewhere. Images built as automated builds will have links to a source repository with a Dockerfile, but for images that were manually built and pushed you're limited to whatever folks publish in the description.

You could try contacting the image maintainer.

Upvotes: 2

Related Questions