|
1 | | -# DockerSlice: Ship Only The Latest Layers You Update |
| 1 | +# DockerDiff: Diff Only The Latest Layers You Update |
| 2 | + |
| 3 | +An efficient Docker image transfer system that extracts the diff of two images and loads only the diff into the server. (designed for offline docker users) |
| 4 | + |
2 | 5 |
|
3 | | -An efficient Docker image transfer system that extracts and merges necessary image layers. (designed for offline docker users) |
4 | 6 | <img width="688" alt="image" src="https://github.com/user-attachments/assets/6f367d37-709b-4f7b-8109-6cba191a3e42" /> |
5 | 7 |
|
6 | | -# How to Use? |
7 | 8 |
|
8 | | -**Step 1:** Clone and run the DockerSlice system (`dslice base run`) on both your online and offline servers. This will set up the DockerSlice registry. |
| 9 | +# Getting Started |
9 | 10 |
|
10 | | -**Step 2**: You can use DockerSlice in two ways: |
| 11 | +### Install DockerDiff |
| 12 | +``` |
| 13 | +git clone https://github.com/junwha/DockerDiff |
| 14 | +echo "export PATH=$(pwd)/DockerDiff:\$PATH" >> ~/.bashrc && source ~/.bashrc |
| 15 | +``` |
11 | 16 |
|
12 | | -A. **Share a Common Base Image:** |
| 17 | +### Basic Usage: Build on the base image, and load the diff |
13 | 18 |
|
14 | | -1. Push the [base images](#docker-base-images) to both servers. |
| 19 | +1. Push the [base image](#docker-base-images) into the offline registry server |
15 | 20 |
|
16 | | - `dslice push junwha/dslice-base-torch:py3.10-torch2.4.1` |
| 21 | + i. Run the registry server `ddiff server` (optional, you can use your own server by setting the env variable DDIFF_URL) |
17 | 22 |
|
18 | | -3. Build custom images on top of the shared base images. |
19 | | - |
20 | | - Start with `FROM junwha/dslice-base-torch:py3.10-torch2.4.1` at the top of the Dockerfile |
21 | | - |
22 | | - `docker build -t <TAG> ./` |
23 | | - |
24 | | -4. Save the above layers as a tar.gz file |
| 23 | + ii. `ddiff push <base tag>` |
| 24 | + |
| 25 | +2. Run the ddiff server, and build a new image on top of the base image. |
| 26 | + |
| 27 | + i. Write a Dockerfile with `FROM <base tag>` |
| 28 | + |
| 29 | + ii. Run the registry server `ddiff server`. This will generate the diff file `<new>-<version>.tar.gz` |
25 | 30 |
|
26 | | - `dslice save <TAG>` (`<TAG>.tar.gz` will be created) |
27 | | - |
28 | | -5. Transfer only the new layers (`<TAG>.tar.gz`) above the base, minimizing data transfer. |
29 | | -6. Load the tar.gz file at the offline server |
30 | | - |
31 | | - `dslice load <TAG>.tar.gz` |
32 | | - |
33 | | -B. **Partial Updates:** |
34 | | - |
35 | | -- When a Docker image on the offline server needs an update, make an update on the image online (e.g., install a package). |
36 | | -- Then, move only the updated layers to the offline server. |
37 | | - |
38 | | -# Commands (will be updated) |
39 | | -./dslice {base|push|pull|delete|save|build|load} |
40 | | -- base {save|load} |
41 | | - - run ([volume folder]): run dslice registry (online server) |
42 | | - - save [base tarball path]: save dslice registry with base images as a tarball |
43 | | - - load [base tarball] ([install directory]): load dslice registry from the tarball |
44 | | - - pull [TAG1] [TAG2] ... [TAGN]: pull one or more images as base images |
45 | | -- push [TAG1] [TAG2] ... [TAGN]: push one or more images into the registry |
46 | | -- pull [TAG1] [TAG2] ... [TAGN]: pull one or more images from the registry |
47 | | -- delete [TAG1]: delete the specified image from the registry |
48 | | -- save [TAG]: |
49 | | - 1. push the image into registry and exclude mounted blobs from target blobs |
50 | | - 2. copy target blobs and image manifest |
51 | | - 3. archive the partial image |
52 | | -- build [docker build args]: |
53 | | - 1. build an image from Dockerfile (docker build) |
54 | | - 2. save image as a tarball (save) |
55 | | -- load [image tarball]: |
56 | | - 1. extract the image to the registry (blobs, manifest) |
57 | | - 2. restart the container and pull the image the local |
| 31 | + `ddiff build -t <new tag>:<version> ./` |
| 32 | + |
| 33 | +3. Transfer only the diff file (`<new tag>-<version>.tar.gz`) to the offline server |
| 34 | + |
| 35 | +4. Load the diff file at the offline server |
| 36 | + |
| 37 | + `ddiff load <new tag>-<version>.tar.gz` |
| 38 | + |
| 39 | +### Diff the existing two images |
| 40 | + |
| 41 | +1. Make a diff file (`<new tag>-<version>.tar.gz`) of the target image from the base image |
| 42 | + |
| 43 | + `ddiff diff <base tag> <target tag>` |
| 44 | + |
| 45 | +2. Transfer the diff file and load at the offline server |
| 46 | + |
| 47 | + `ddiff load <new tag>-<version>.tar.gz` |
| 48 | + |
| 49 | +### Patch the image in the offline |
| 50 | + |
| 51 | +1. Modify the existing Dockerfile or make a new Dockerfile on top of the image in the offline (FROM <offline tag>:<prev version>) |
| 52 | + |
| 53 | +2. Build the Dockerfile with ddiff |
| 54 | + |
| 55 | + `ddiff build -t <offline tag>:<new version> ./` |
| 56 | + |
| 57 | +3. Transfer the diff file and load at the offline server |
| 58 | + |
| 59 | + `ddiff load <offline tag>-<new version>.tar.gz` |
| 60 | + |
| 61 | +# Commands |
| 62 | + |
| 63 | +**Usage**: `ddiff <command> <args...>` |
| 64 | + |
| 65 | +**Commands** |
| 66 | + - `server` - Run the registry server |
| 67 | + - `push` `<tag 1> ... <tag n>` - Push one or more images |
| 68 | + - `pull` `<tag 1> ... <tag n>` - Pull one or more images |
| 69 | + - `diff` `<base> <target>` - Diff the target image from the base image |
| 70 | + - `load` `<tar file>` - Load the target image from diff file |
| 71 | + - `build` `<args>` - Build the image and diff from base (FROM ...) |
58 | 72 |
|
59 | 73 | # Docker base images |
60 | | -For easier sharing of base images, DockerSlice provides several pre-configured base images: |
| 74 | +For easier sharing of base images, DockerDiff provides several pre-configured base images: |
| 75 | + |
| 76 | +- [ddiff-base](https://hub.docker.com/r/junwha/ddiff-base): A CUDA base image with essential tools (e.g., Git, Vim, OpenSSH). |
| 77 | +- [ddiff-base-py](https://hub.docker.com/r/junwha/ddiff-base-py): A Conda-based image with a specific Python version, built on `ddiff-base`. |
| 78 | +- [ddiff-base-torch](https://hub.docker.com/r/junwha/ddiff-base-torch): A PyTorch image with a specific Python version, built on `ddiff-base-py`. |
61 | 79 |
|
62 | | -- [dslice-base](https://hub.docker.com/r/junwha/dslice-base): A CUDA base image with essential tools (e.g., Git, Vim, OpenSSH). |
63 | | -- [dslice-base-py](https://hub.docker.com/r/junwha/dslice-base-py): A Conda-based image with a specific Python version, built on `dslice-base`. |
64 | | -- [dslice-base-torch](https://hub.docker.com/r/junwha/dslice-base-torch): A PyTorch image with a specific Python version, built on `dslice-base-py`. |
| 80 | +# Requirements |
| 81 | +- Python 3.X |
0 commit comments