Article directory
foreword
Since the last time I found a tool to extract dockerfile from docker image, today we found two interesting docker gadgets, one of which also extracts dockerfile.
Two interesting docker gadgets: runlike and whaler
- runlike: print out the startup command of the container through the container
- whaler: export dockerfile through image
runlike: print out the startup command of the container through the container
Method 1: Install directly through pip
If there is no pip, you can choose to install pip first; reference: [Linux] install pip (detailed tutorial)
pip install runlike
Method 2: Free installation and use through the container method
Use the method of setting aliases. If you use it for a long time, you can set it as a permanent alias; refer to: How to set a permanent alias in Linux
alias runlike="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock assaflavie/runlike"
This method needs to pull the image and automatically create a container to load this command. Personally, I feel that the first method is better;
usage
runlike 容器名/容器id
runlike -p 容器名/容器id
What runlike prints is a lot on one line; for example:
runlike -p plus the -p parameter will sort it out line by line for you, which looks more concise; for example:
whaler: export dockerfile through image
Usually, many different images may be built, such as maintaining some basic Docker images, wanting to see how the Docker images of some public repositories are built, or because the Dockerfile of the image that was built at that time cannot be found because of no maintenance for a long time, or because the network cannot be viewed. , it is very important to be able to export the Dockerfile from the image. Here you can export it quickly through the whaler. Here we still don't install it, and use the whaler command to set the alias in a containerized way, which is easy to use; in fact, he and I wrote another command It is the same dfimage, and it has the same effect;
how to extract the dockerfile from the docker image
For the same setting of permanent aliases, please refer to: The method of setting permanent aliases in Linux
alias whaler="docker run -t --rm -v /var/run/docker.sock:/var/run/docker.sock:ro pegleg/whaler"
After setting the alias, you can export the dockerfile from the image;
usage
whaler 镜像名/镜像id
whaler -sV=1.36 镜像名/镜像id
Using the whaler directly will report an error, you need to add a parameter;
In this way, it can come out, or it can be redirected to a file > a.txt; of
course, this is relatively small, because this mirror is only 1M, so it will not output a lot of things, and interested friends can write it by themselves A mirror, or go to the official website to pull a larger mirror, and then test it again, there will be many, many, especially detailed;
related articles
Article 1: Install pip in [Linux] (detailed tutorial)
Article 2: How to set permanent alias alias in Linux
Article 3: How to extract dockerfile from docker image