0% found this document useful (0 votes)
9 views5 pages

Lesson 8 Docker Repository

The document explains how to publish Docker images to Docker Hub and create tar zip files from Docker containers and images. It details the steps for tagging and pushing images to Docker Hub, as well as using 'docker export' and 'docker save' commands to create zip files. Additionally, it highlights the differences between the export and save methods, including their impact on file size and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views5 pages

Lesson 8 Docker Repository

The document explains how to publish Docker images to Docker Hub and create tar zip files from Docker containers and images. It details the steps for tagging and pushing images to Docker Hub, as well as using 'docker export' and 'docker save' commands to create zip files. Additionally, it highlights the differences between the export and save methods, including their impact on file size and functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Lesson 8 Docker Repository

A Docker repository is a centralized location for storing images. Docker


Hub (https://hub.docker.com/)” is the largest public repository, which stores
tremendous images for users to download. Public repositories in China include
Ali Cloud and Netease Cloud.

1. Publish Image to Docker Hub


① Address: https://hub.docker.com/. Register an account first.
② Ensure that you can successfully log in to your account.

③ Use the “tag” command to modify the image name.


The standard for publishing an image to “docker hub” is: “docker push”
register username/image name
In this case, the registered username is “tao082”, and the image name
should be modified first.
1) Press “Ctrl+Alt+T” to open the command line terminal, and enter
“docker images” to check the images on the master.

2) Enter “docker tag 30555f5a4f74 tao082/debian:1.1” in the terminal to


modify the image names.

1
3) Enter “docker images” in the terminal to see the modified image
names.

① Log in to “docker hub” to publish the images:


4) Enter “docker login -u tao082” in the terminal and press “Enter”. Input
the password to log in.

5) Enter “docker push tao082/debian:1.1” in the terminal and press “Enter”


to publish the images.

② Access the “docker hub”, and you can view that the images have been
successfully published.

2
2. Publish Image to Create “tar” Zip
The methods below are performed in the host, not in the Docker.
Method 1: “docker export” and “docker import” (export zip from containers)
1) Press “Ctrl+Alt+T” to open the command line terminal, and enter
“docker ps” to display the latest containers in the master.

2) Enter “docker export efe969b704a7 >debian.tar” in the terminal to


export the container “efe969b704a7” as “debian.tar”.

You can see the exported containers under the current path.

3) Enter “cat /home/pi/debian.tar | docker import - test/debian:v1” in the


terminal. Import the path where the container is into “/home/pi/debian.tar”,
name the image “test/debian” and the tag “v1”.

4) Enter “docker images” in the terminal and press “Enter” to view the
container information in the master.

3
Method 2: “docker save” and “docker load” (export zip from images)
1) Press “Ctrl+Alt+T” to open the command line terminal, and enter
“docker images” to view the latest images in the master.

2) Enter “docker save -o debian_1.1.tar debian:latest” in the terminal.


Press“Enter” to create the images into a zip.

You can see the exported containers under the current path.

3) Enter “docker load -i debian_1.1.tar” in the terminal. After the zip is


created, use “docker load” to import it into the image library.

Differences between these two methods:


“docker export” is generated from the container, and “docker save” is
4
created in the image. “docker export” saves smaller packages than “docker
save”. The reason is that the latter saves the entire layered file system, while
the former only exports one layer of the file system. Both “docker import” and
“docker load” can be used to generate images. However, the former allows for
renaming the images and specifying new version numbers, the latter cannot
offer this option.

You might also like