Giter Club home page Giter Club logo

dfimage's Introduction

GitHub Stats Overview GitHub Stats Languages

dfimage's People

Contributors

bugficks avatar codacy-badger avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar laniksj avatar pczerkas avatar snyk-bot avatar theodrim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dfimage's Issues

dfimage container not reversing any container tried, including itself

I tried using the script as described in the MD for the following:
docker pull factoriotools/factorio
dfimage factoriotools/factorio

--> I get the following after a good wait:
Traceback (most recent call last):
File "/root/entrypoint.py", line 57, in
main = MainObj()
File "/root/entrypoint.py", line 16, in init
self._get_image(argv[-1])
File "/root/entrypoint.py", line 29, in _get_image
if repo_tag in i['RepoTags']:
TypeError: argument of type 'NoneType' is not iterable

So then I thought, let'e try this:
docker pull ghcr.io/laniksj/dfimage
dfimage ghcr.io/laniksj/dfimage

--> and I got the same thing
Traceback (most recent call last):
File "/root/entrypoint.py", line 57, in
main = MainObj()
File "/root/entrypoint.py", line 16, in init
self._get_image(argv[-1])
File "/root/entrypoint.py", line 29, in _get_image
if repo_tag in i['RepoTags']:
TypeError: argument of type 'NoneType' is not iterable

Is the system broken or am I missing something obvious?

๐Ÿ› [BUG] - `unable to parse history from json file`

Description

Attempting to generate Dockerfile from image, receiving this error message after a few minutes of processing:
unable to parse history from json file

Docker Config

19.03.5

Reproduction steps

Run `docker run --rm -v /var/run/docker.sock:/var/run/docker.sock alpine/dfimage mconan479/some-image:v0.1`

Screenshots

No response

Logs

Analyzing mconan479/some-image:v0.1
Docker Version: 19.03.5
GraphDriver: overlay2
Environment Variables
|PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|container=oci
|SHELL=/bin/sh
|OTHER_VARS...

Image user
|Image is running as User: default

Potential secrets:
unable to parse history from json file

OS

Mac

๐Ÿ› [BUG] - dfimage reports Error

Description

when I run dfimage MY_IMAGE:TAG, it reports:

File "/usr/lib/python3.11/site-packages/urllib3/connectionpool.py", line 496, in _make_request
    conn.request(
TypeError: HTTPConnection.request() got an unexpected keyword argument 'chunked'

Docker Config

1. Open Docker Desktop
2. Docker Desktop > About

Reproduction steps

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

No response

doesn't work with image "devopsqa/fortify"

docker pull laniksj/dfimage
alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm laniksj/dfimage"
docker pull devopsqa/fortify

dfimage devopsqa/fortify
Traceback (most recent call last):
  File "/root/entrypoint.py", line 56, in <module>
    __main__ = MainObj()
  File "/root/entrypoint.py", line 16, in __init__
    self._get_image(argv[-1])
  File "/root/entrypoint.py", line 32, in _get_image
    raise ImageNotFound("Image {} not found\n".format(img_hash))
__main__.ImageNotFound: Image devopsqa/fortify not found

I am looking for a image to run with fortify, and find it in hub.docker.com. I 'd like to reverse its Dockerfile. this image devopsqa/fortify is huge,

docker images devopsqa/fortify
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
devopsqa/fortify    latest              9db34bb78a6e        2 years ago         3.04GB

๐Ÿ’ก [REQUEST] - Dockerfile from docker image tarball without dependency on docker

Start Date

05/07/2024

Implementation PR

Not yet.

Reference Issues

No response

Summary

I was reading the Docker container spec, and it looks like extracting history information from a Docker image that has been saved as a tar file would primarily involve reading a JSON file and pulling information from a few fields. Using this could enable re-creating the Dockerfile commands used to create a Docker image that has been exported as a tar file, without re-importing it into docker. Not depending on having a docker unix socket available would also enable this functionality to work on systems using alternative container runtimes (e.g. podman) that may not expose a docker compatible unix socket.

Basic Example

Basically, enable running dfimage on a Docker image that has been saved/exported to a tar file -- without any dependency on having docker installed (or communicating with docker). e.g. dfimage saved_docker_image.tar should be able to reproduce the sequence of dockerfile commands used to create it.

Drawbacks

Getting local tag names associated with image IDs referenced wouldn't be possible if docker isn't installed -- however, if docker is present, the existing method of calling out to Docker over the unix socket would still be used; there shouldn't be any impact on existing use cases.

Unresolved questions

No response

Image not found

$dfimage marksugar/redis:5.0.0

Traceback (most recent call last):
File "/root/entrypoint.py", line 56, in
main = MainObj()
File "/root/entrypoint.py", line 16, in init
self._get_image(argv[-1])
File "/root/entrypoint.py", line 32, in _get_image
raise ImageNotFound("Image {} not found\n".format(img_hash))
main.ImageNotFound: Image marksugar/redis:5.0.0 not found

๐Ÿ› [BUG] - TypeError: 'NoneType' object is not subscriptable

Description

When executing the following command against any image I have

docker run -v /var/run/docker.sock:/var/run/docker.sock laniksj/dfimage:latest

I get an error instead of the Dockerfile output

Docker Config

1. Open Docker Desktop
2. Docker Desktop > About

Docker Desktop Version = 
4.4.2 (73305)

Reproduction steps

1. Execute docker run -v /var/run/docker.sock:/var/run/docker.sock laniksj/dfimage:latest container:test
2. Expect to see the resulting Dockerfile output
3. Instead get an error for entrypoint.py 
Downloaded newer image for laniksj/dfimage:latest
Traceback (most recent call last):
  File "/app/entrypoint.py", line 126, in <module>
    __main__ = MainObj()
               ^^^^^^^^^
  File "/app/entrypoint.py", line 23, in __init__
    self._get_layers_with_images()
  File "/app/entrypoint.py", line 69, in _get_layers_with_images
    self.layers_with_images[last_layer_id] = i["RepoTags"][0]
                                             ~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

Mac

TypeError: argument of type 'NoneType' is not iterable

Description

dfimage 192.168.1.94:443/library/xmrig/xmrig:v1

Traceback (most recent call last):
File "/root/entrypoint.py", line 56, in
main = MainObj()
File "/root/entrypoint.py", line 16, in init
self._get_image(argv[-1])
File "/root/entrypoint.py", line 29, in _get_image
if repo_tag in i['RepoTags']:
TypeError: argument of type 'NoneType' is not iterable
root@jack-virtual-machine:/home/jack/test/ttttt# echo dfimage
dfimage
root@jack-virtual-machine:/home/jack/test/ttttt# echo $dfimage

root@jack-virtual-machine:/home/jack/test/ttttt# docker inspect 192.168.1.94:443/library/xmrig/xmrig:v1
[
{
"Id": "sha256:2a06e9574854723b606ef03dda327158edd3525c8454661712db49a5548bc0d0",
"RepoTags": [
"192.168.1.94:443/library/xmrig/xmrig:v1"
],

Docker Config

1. Open Docker Desktop
2. Docker Desktop > About

Reproduction steps

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

Screenshots

![DESCRIPTION](LINK.png)

Logs

No response

OS

No response

๐Ÿ› [BUG] - RUN prefix on each command if multi stage build is used

Description

RUN prefix on each command if multi stage build is used
Snipaste_2024-05-04_14-25-08
Also, it seems #155 still exists here.

Docker Config

Client:
 Version:           25.0.3
 API version:       1.44
 Go version:        go1.20.12
 Git commit:        4debf41
 Built:             Mon Feb 12 00:00:00 2024
 OS/Arch:           linux/amd64
 Context:           default

Server:
 Engine:
  Version:          25.0.3
  API version:      1.44 (minimum version 1.24)
  Go version:       go1.20.12
  Git commit:       f417435
  Built:            Mon Feb 12 00:00:00 2024
  OS/Arch:          linux/amd64
  Experimental:     false

Reproduction steps

docker run -v /var/run/docker.sock:/var/run/docker.sock --rm ghcr.io/laniksj/dfimage portainer/portainer-ce:latest

Screenshots

No response

Logs

No response

OS

Linux

FROM attribute in the output Dockerfile is the image itself

Describe the bug
When used to get the Dockerfile for gitlab/gitlab-runner:latest, the FROM attribute in the output Dockerfile is gitlab/gitlab-runner:latest and not alpine:3.12.0 as it should be.

To Reproduce
Steps to reproduce the behavior run the following script:

docker pull quay.io/laniksj/dfimage
alias dfimage="docker run -v /var/run/docker.sock:/var/run/docker.sock --rm quay.io/laniksj/dfimage"
dfimage gitlab/gitlab-runner:latest

Expected behavior
Expected to see the following:
FROM alpine:3.12.0

Actual behavior
This is the actual output.
Check the first line FROM attribute.

FROM gitlab/gitlab-runner:latest
ADD file:1b4ec50586b9f0621095f51ee6baecc00a7f6d95b4a04e3bedc5393b28bc8a54 in /
RUN /bin/sh -c set -xe 		\
    && echo '#!/bin/sh' > /usr/sbin/policy-rc.d 	\
    && echo 'exit 101' >> /usr/sbin/policy-rc.d 	\
    && chmod +x /usr/sbin/policy-rc.d 		\
    && dpkg-divert --local --rename --add /sbin/initctl 	\
    && cp -a /usr/sbin/policy-rc.d /sbin/initctl 	\
    && sed -i 's/^exit.*/exit 0/' /sbin/initctl 		\
    && echo 'force-unsafe-io' > /etc/dpkg/dpkg.cfg.d/docker-apt-speedup 		\
    && echo 'DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' > /etc/apt/apt.conf.d/docker-clean 	\
    && echo 'APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };' >> /etc/apt/apt.conf.d/docker-clean 	\
    && echo 'Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";' >> /etc/apt/apt.conf.d/docker-clean 		\
    && echo 'Acquire::Languages "none";' > /etc/apt/apt.conf.d/docker-no-languages 		\
    && echo 'Acquire::GzipIndexes "true"; Acquire::CompressionTypes::Order:: "gz";' > /etc/apt/apt.conf.d/docker-gzip-indexes 		\
    && echo 'Apt::AutoRemove::SuggestsImportant "false";' > /etc/apt/apt.conf.d/docker-autoremove-suggests
RUN /bin/sh -c [ -z "$(apt-get indextargets)" ]
RUN /bin/sh -c mkdir -p /run/systemd \
    && echo 'docker' > /run/systemd/container
CMD ["/bin/bash"]
RUN ARG TARGETPLATFORM
RUN ENV DEBIAN_FRONTEND=noninteractive
RUN RUN |1 TARGETPLATFORM=linux/amd64 /bin/sh -c apt-get update -y \
    &&     apt-get install -y --no-install-recommends         apt-transport-https         ca-certificates         curl         git         wget         tzdata         openssh-client     \
    && rm -rf /var/lib/apt/lists/* # buildkit
RUN ARG DOCKER_MACHINE_VERSION
RUN ARG DUMB_INIT_VERSION
RUN ARG GIT_LFS_VERSION
RUN COPY gitlab-runner_*.deb checksums-* install-deps install-gitlab-runner /tmp/ # buildkit
RUN RUN |4 TARGETPLATFORM=linux/amd64 DOCKER_MACHINE_VERSION=0.16.2 DUMB_INIT_VERSION=1.2.2 GIT_LFS_VERSION=2.11.0 /bin/sh -c /tmp/install-deps "${TARGETPLATFORM}" "${DOCKER_MACHINE_VERSION}" "${DUMB_INIT_VERSION}" "${GIT_LFS_VERSION}" # buildkit
RUN COPY entrypoint / # buildkit
RUN RUN |4 TARGETPLATFORM=linux/amd64 DOCKER_MACHINE_VERSION=0.16.2 DUMB_INIT_VERSION=1.2.2 GIT_LFS_VERSION=2.11.0 /bin/sh -c chmod +x /entrypoint # buildkit
RUN STOPSIGNAL SIGQUIT
RUN VOLUME [/etc/gitlab-runner /home/gitlab-runner]
RUN ENTRYPOINT ["/usr/bin/dumb-init" "/entrypoint"]
RUN CMD ["run" "--user=gitlab-runner" "--working-directory=/home/gitlab-runner"]
  • OS: macos
  • Docker Version: 19.03.13

image not found

dfimage looks broken

workaround: use https://github.com/mrhavens/Dedockify

similar to #35

imageName=xxx/yyy:latest
docker pull $imageName
docker images # -> get image ID
imageId=zzzzzzzzzz

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock ghcr.io/laniksj/dfimage $imageId
Traceback (most recent call last):
  File "/root/entrypoint.py", line 56, in <module>
    __main__ = MainObj()
  File "/root/entrypoint.py", line 16, in __init__
    self._get_image(argv[-1])
  File "/root/entrypoint.py", line 32, in _get_image
    raise ImageNotFound("Image {} not found\n".format(repo_tag))
__main__.ImageNotFound: Image zzzzzzzzzz not found

# compare: dedockify
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock mrhavens/dedockify $imageId
# -> ok. dockerfile is printed to stdout

# compare: dockerfile-from-image
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock centurylink/dockerfile-from-image $imageName
/usr/lib/ruby/gems/2.2.0/gems/docker-api-1.24.1/lib/docker/connection.rb:42:in `rescue in request': 400 Bad Request: malformed Host header (Docker::Error::ClientError)

๐Ÿ’ก [REQUEST] - PyPI package?

pip install dfimage would be convenient. Would you accept a PR with the changes needed to make this a pip installable package (along with a GitHub Actions workflows for publishing new versions to PyPI)?

[Lock] Configuration error

Lock has encountered a configuration error in lock.yml.

ValidationError: child "lockLabel" fails because ["lockLabel" must be a string, "lockLabel" must be one of [false]]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.