Is it possible to extract the Dockerfile from a docker container

前端 未结 3 557
死守一世寂寞
死守一世寂寞 2020-12-23 20:32

I\'m just starting out with Docker, and it would be very helpful to be able to see the Dockerfiles used to create existing docker images.

Even if the image was buil

相关标签:
3条回答
  • 2020-12-23 20:49

    There's a project dockerfile-from-image which could help you to do it directly.

    It requires a single CLI command to recover the Dockerfile:

    docker run -v /var/run/docker.sock:/var/run/docker.sock centurylink/dockerfile-from-image <IMAGE_TAG_OR_ID>

    One has to have Docker already installed.

    0 讨论(0)
  • 2020-12-23 21:07

    You have docker history <image> that is very helpful. It can even be used to generate a dockerfile if none of the steps involved stdin.

    If a step as stdin, the only way to know what happened would be to do docker logs <container id parent>, but if you do not have the container, you can't.

    0 讨论(0)
  • 2020-12-23 21:10

    There is undocker available now. We can install it by using the pip command.

    pip install git+https://github.com/larsks/undocker/ 
    

    and use

    docker save IMAGE_NAME | undocker -i -o IMAGE_NAME 
    

    to extract the files from docker.

    https://github.com/larsks/undocker/

    0 讨论(0)
提交回复
热议问题