Directory
- Overview
- docker common commands
- download
- Export
- Import image
- Finish
Overview
Docker common commands
The commands used in this chapter are summarized here, with use cases following.
Command | Function |
---|---|
docker images | Show images |
docker rmi $(docker images -q) | Delete all images on the system |
docker rmi -f | Force deletion of multiple images: docker rmi -f nginx mysql |
docker save -o |
|
docker load -i |
Import image |
Download
Production machines are generally no external network environment, so docker needs to be installed offline, and the image also needs to be installed offline.
Therefore, you need a machine connected to the Internet. First download the image and then export it.
appledeMacBook-Pro:~ hyl$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE pangliang/rocketmq-console-ng latest ce1afb55c045 4 years ago 118MB rocketmqinc/rocketmq latest 09bbc30a03b6 4 years ago 380MB appledeMacBook-Pro:~ hyl$ appledeMacBook-Pro:~ hyl$ docker rmi $(docker images -q) Untagged: pangliang/rocketmq-console-ng:latest Untagged: pangliang/rocketmq-console-ng@sha256:630eb2fb9f144637bb6f77af37e23426e0c0596b0d46873f1c921f8f6c4aa17a Deleted: sha256:ce1afb55c04576af89153d98789d55d8bca0ed5c30a456bc9c9161859a9e6f9f Deleted: sha256:fdde7851a1539da25abd154a97e6f47a5166256e1ff37768d8e92016b37f54ae Deleted: sha256:aba8cd4318a8a15f59f305368e49cc3bbd0d6d72171a0b24d08cc00513b14ef4 Deleted: sha256:c318fbba92645a83843c387bd78497e7b143ecc7f5ed99dcb7d38fc62442c02a Deleted: sha256:f1b5933fe4b5f49bbe8258745cf396afe07e625bdab3168e364daf7c956b6b81 Untagged: rocketmqinc/rocketmq:latest Untagged: rocketmqinc/rocketmq@sha256:b08556227ad8d169b7927f4c48335877cb10060e6781374ce5a644ea29f6fbe1 Deleted: sha256:09bbc30a03b682786ad205beb772a382d4cecc8a521206d7b3c50e95fb725530 Deleted: sha256:9b56b922584897d7008163dc149c70a987fac1ae6b1929f4412efe9f8c2ede78 Deleted: sha256:33183233106a7e3aa85b0d2bc1d65260f9c4d78040c78370940ecc2331ea313d Deleted: sha256:2f228f2a23dfa6754aede6994c84fb52386e0bb5a02226f0070f0eb0f44fd85e Deleted: sha256:8f9cb5d760f829ad52a340f773ff645db0138d0583b8ccf2b62554480707554c Deleted: sha256:7fa827024c4d1c03f341b9f5a28bc3cf37264c431ec4a3f7abdafeaf990f45d8 Deleted: sha256:5cc9537c34c58cda2cf83d0d4fa991a508f89b1a86eada4d190878785b6f9172 Deleted: sha256:ef8da6bbb9df05a886aae9a4175664802cef24582203f10dfe1d84ce00f8db1d Deleted: sha256:071d8bd765171080d01682844524be57ac9883e53079b6ac66707e192ea25956 appledeMacBook-Pro:~ hyl$ docker images REPOSITORY TAG IMAGE ID CREATED SIZE
Download image
appledeMacBook-Pro:~ hyl$ docker pull influxdb:1.8 1.8: Pulling from library/influxdb 2f088d622efd: Pull complete de448b80f064: Pull complete 469105de3319: Pull complete cdad387b3290: Pull complete b9b6af5df828: Pull complete 20272ddaf2bf: Pull complete 708944893048: Pull complete Digest: sha256:f02e9d97bd1edf36f343d0478b9e4d3bf0f4a7c30d59c4edca6acf2b6065f2a9 Status: Downloaded newer image for influxdb:1.8 docker.io/library/influxdb:1.8 appledeMacBook-Pro:~ hyl$ docker pull grafana/grafana Using default tag: latest Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: TLS handshake timeout appledeMacBook-Pro:~ hyl$ docker pull grafana/grafana Using default tag: latest latest: Pulling from grafana/grafana 7264a8db6415: Pull complete 3cf7ed17dad5: Pull complete 00fbaa4ff278: Pull complete 1712a81b1c5b: Pull complete b82f661477d7: Pull complete 85d88afc7ec6: Pull complete 5aeff27f6208: Pull complete 2309246adff5: Pull complete 4a6fe4caa3c7: Pull complete 6309adfe5521: Pull complete Digest: sha256:1ee0c54286b8ca09a3dd1419ff8653e7780a148a006ac088544203bb0affe550 Status: Downloaded newer image for grafana/grafana:latest docker.io/grafana/grafana:latest appledeMacBook-Pro:~ hyl$
Export
Export and package the downloaded image
, upload it to an offline server, and import it.
docker save -o /Users/hyl/Desktop/jk/influxdb.tar influxdb:1.8 docker save -o /Users/hyl/Desktop/jk/grafana.tar grafana/grafana:latest
The operation is as follows:
The export process may take some time, depending on the size of the image, so be patient.
Import image
After the export is complete, you can use the docker load
command to verify the exported image. The following is an example command to load an image:
[root@hadoop01 ~]# docker load -i ./influxdb.tar 53ae7e5bcde8: Loading layer [================================================ =====>] 129.4MB/129.4MB 47a0492361a1: Loading layer [================================================ =====>] 29.53MB/29.53MB ea498917da7b: Loading layer [================================================ =====>] 10.75kB/10.75kB 18ae329703f8: Loading layer [================================================ =====>] 154MB/154MB 63f6173a2112: Loading layer [================================================ =====>] 3.072kB/3.072kB 99108cfee517: Loading layer [================================================ =====>] 2.048kB/2.048kB 3ab566fe20ca: Loading layer [================================================ =====>] 5.632kB/5.632kB Loaded image: influxdb:1.8 [root@hadoop01 ~]# docker load -i ./grafana.tar 4693057ce236: Loading layer [================================================ =====>] 7.626MB/7.626MB bdf330023361: Loading layer [================================================ =====>] 2.56kB/2.56kB 018ee2d8caca: Loading layer [================================================ =====>] 8.495MB/8.495MB 7ccfea30313d: Loading layer [================================================ =====>] 10.19MB/10.19MB fb7a544ac307: Loading layer [================================================ =====>] 162.3kB/162.3kB 4ee20b1f5366: Loading layer [================================================ =====>] 89.6kB/89.6kB 5892380a6ea3: Loading layer [================================================ =====>] 189.1MB/189.1MB 3c537f66dd33: Loading layer [================================================ =====>] 191.2MB/191.2MB bf5a90fccd9f: Loading layer [================================================ =====>] 37.89kB/37.89kB e14e42fdf9d7: Loading layer [================================================ =====>] 5.12kB/5.12kB Loaded image: grafana/grafana:latest [root@hadoop01 ~]#
The import was successful as shown below
End
At this point, the import and export of docker images is over. If you have any questions, please leave them in the comment area.