docker_practice/image/other.md

86 lines
3.3 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#
使 `Dockerfile`
## rootfs
`docker import [选项] <文件>|<URL>|- [<仓库名>[:<标签>]]`
Web `/`
[OpenVZ](https://openvz.org) 的 Ubuntu 16.04 [模板](https://wiki.openvz.org/Download/template/precreated)的镜像:
```bash
$ docker import \
http://download.openvz.org/template/precreated/ubuntu-16.04-x86_64.tar.gz \
openvz/ubuntu:16.04
Downloading from http://download.openvz.org/template/precreated/ubuntu-16.04-x86_64.tar.gz
sha256:412b8fc3e3f786dca0197834a698932b9c51b69bd8cf49e100c35d38c9879213
```
`ubuntu-16.04-x86_64.tar.gz` `openvz/ubuntu:16.04`
`docker image ls`
```bash
$ docker image ls openvz/ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
openvz/ubuntu 16.04 412b8fc3e3f7 55 seconds ago 505MB
```
```bash
$ docker history openvz/ubuntu:16.04
IMAGE CREATED CREATED BY SIZE COMMENT
f477a6e18e98 About a minute ago 214.9 MB Imported from http://download.openvz.org/template/precreated/ubuntu-16.04-x86_64.tar.gz
```
## Docker `docker save` `docker load`
Docker `docker save` `docker load` Docker Registry 使 Docker Registry使 Docker Hub 使 Registry
###
使 `docker save`
`alpine`
```bash
$ docker image ls alpine
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest baa5d63471ea 5 weeks ago 4.803 MB
```
```bash
$ docker save alpine -o filename
$ file filename
filename: POSIX tar archive
```
filename
****
使 `gzip`
```bash
$ docker save alpine | gzip > alpine-latest.tar.gz
```
`alpine-latest.tar.gz`
```bash
$ docker load -i alpine-latest.tar.gz
Loaded image: alpine:latest
```
`ssh` `pv` Linux
```bash
docker save <镜像名> | bzip2 | pv | ssh <用户名>@<主机名> 'cat | docker load'
```