2 docker image

3. Docker image

3.1 Common commands for image management

# 列出镜像docker images
# 列出正则匹配的镜像docker images ce*
# images只会列出镜像的基本信息, 详细信息可以通过inspect命令docker inspect [name]/[container id]
# 搜索镜像dockersearch [name]
# 拉取镜像docker pull [name]
# 删除镜像docker rmi [name]/[contaniner id]

Repository: The name of the warehouse where the image is located
Tag: Image version
IMAGE ID: Image ID
CREATE: Image creation event
SIZE: Image size

3.2 Build your own image

We can do it manually or through dockfile to build our own image.The way of dockfile will be introduced separately later.

3.2.1 Running the container

docker run -it centos: 7
docker run: start the container
-it: enter the container in interactive mode

3.2.2 Custom installation software

Install the software you need yourself:
Example:
yum install -y vim

3.2.3 Save your own image

Reopen a window:

# 查看docker容器运行的进程
docker ps
  
docker commit 29ebec590397 centos_with_vim
# 或者, romantic_swanson 是系统随机给起的名字
docker commit romantic_swanson centos_with_vim

3.3 Mirror migration

3.3.1 Export image

docker save repository:tag/imageId > /root/xx.tar.gz

3.3.2 Import image

docker load < /root/xx.tar.gz

3.3.3 Import and export by CONTAINER ID

下面e13c085ecbdf 是通过docker ps 查看的CONTAINER ID
docker export -o myexportcontainer1.tar e13c085ecbdf
 
或者使用
docker import myexportcontainer1.tar mycentos_imported

Guess you like

Origin www.cnblogs.com/huningfei/p/12706404.html