lavie / runlike

Given an existing docker container, prints the command line necessary to run a copy of it.
Other
1.99k stars 118 forks source link

feat: directory mounting supports bind and volume modes #115

Closed DDSDerek closed 2 months ago

DDSDerek commented 4 months ago

In the old code, using Config.Volumes and HostConfig.Binds to get volume can only display volume mounts in bind mode normally. I changed it to get the volume through the Mounts data string, so that both bind and volume mounting can be obtained normally.

[
    {
        "Id": "81da5acdde68bc319ebdcf306112ee7b2ba3ad9fd5105a2aeea1bd3d00c042ba",
        "Mounts": [
            {
                "Type": "bind",
                "Source": "/xxxx/data",
                "Destination": "/xxxx/data",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "volume",
                "Name": "31528af375053362a6b7f74650cfc8c39b22808af111581190d8efd30c47aee5",
                "Source": "/xxx/volumes/31528af375053362a6b7f74650cfc8c39b22808af111581190d8efd30c47aee5/_data",
                "Destination": "/xxxx/data",
                "Driver": "local",
                "Mode": "rw",
                "RW": true,
                "Propagation": ""
            }
        ]
    }
]
lavie commented 4 months ago

Cool! Would you kindly add test coverage for this change?

DDSDerek commented 4 months ago

Cool! Would you kindly add test coverage for this change?

FAILED test_runlike.py::TestRunlike::test_network_mode - AssertionError: '--n...
FAILED test_runlike.py::TestRunlike::test_restart_not_present - AssertionErro...

There are currently two errors in the part, but I haven't made any changes, so I can't solve it. Can you help me to solve it?

DDSDerek commented 4 months ago

@lavie I have solved these two problems here. In the latest docker:

DDSDerek commented 4 months ago

@lavie Now the test should pass perfectly.

lavie commented 2 months ago

continued in https://github.com/lavie/runlike/pull/121