是docker容器运行的前提必威,默认值为fasle

Fedora镜像:

导入本地镜像

将导出的镜像文件导入到本地镜像库

[root@docker ~]# docker load --input nginx-img.tar 
54522c622682: Loading layer [==================================================>]  58.44MB/58.44MB
1c3fae42c500: Loading layer [==================================================>]   52.7MB/52.7MB
87823f21b793: Loading layer [==================================================>]  3.584kB/3.584kB
Loaded image: nginx:latest

导出和载入镜像

使用docker savedocker load命令导出和载入镜像

6、存出和载入镜像

创建Dickerfile文件

上边正是二个Dockerfile文件示例

# This is a commit
FROM alpine:3.2
MAINTAINER Jasper Xu <sorex@163.com>

RUN apk update &&      apk add socat &&        rm -r /var/cache/

注:详情见02

ubuntu镜像:

去除镜像

除去本地镜像库中的镜像

[root@docker ~]# docker rmi nginx
Untagged: nginx:latest
Untagged: nginx@sha256:72c7191585e9b79cde433c89955547685db00f3a8595a750339549f6acef7702
Deleted: sha256:c246cd3dd41d35f9deda43609cdeaa9aaf04d3658f9c5e38aad25c4ea5efee10
Deleted: sha256:faff6e89a68845db6912629dd8b5647545f9198c5e312327a853508f25398c4d
Deleted: sha256:17634c028290a76bf93f15b178f7534cca4a38aede119fa760e319019a7bf9c7
Deleted: sha256:54522c622682789028c72c5ba0b081d42a962b406cbc1eb35f3175c646ebf4dc

比如镜像创建了容器,将不恐怕删除该镜像,删除容器后在剔除该镜像

始建镜像

开创镜像有二种办法:

  • 基于本来就有镜像的容器创立

  • 依赖本地模板导入

  • 基于Dockfile创建

1.存出镜像

  docker save命令能够导出镜像到当三步跳件,如下:

[root@linux-node1 ~]# docker save -o ubuntu-14.04-x86_64-minimal.tar.gz ubuntu:14.04
[root@linux-node1 ~]# ll
total 224808
-rw-------. 1 root root      1071 Jan 19  2017 anaconda-ks.cfg
-rw-------  1 root root 230199296 Nov 28 14:40 ubuntu-14.04-x86_64-minimal.tar.gz

6.其他

Arch镜像:

镜像下载

从镜像酒店下载镜像,不点名仓库的地点将暗中认可从Docker Hub官方饭馆下载镜像

不钦命镜像的tag将下载暗中同意latest镜像

docker pull [OPTIONS] NAME[:TAG|@DIGEST]

从docker官方镜像客栈下载nginx镜像

[root@docker yum.repos.d]# docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
e6e142a99202: Pull complete 
8c317a037432: Pull complete 
af2ddac66ed0: Pull complete 
Digest: sha256:72c7191585e9b79cde433c89955547685db00f3a8595a750339549f6acef7702
Status: Downloaded newer image for nginx:latest

从钦命的镜像饭店192.168.0.180/pan 下载镜像

[root@docker ~]# docker pull 192.168.0.180/pan/pod
Using default tag: latest
latest: Pulling from pan/pod
5a865e48f2fd: Pull complete 
a778b52f148e: Pull complete 
8d6f83433b16: Pull complete 
Digest: sha256:a542e98ed123fbba93b820b896d5f563f003bf07b59d5943b591a10f16ce1211
Status: Downloaded newer image for 192.168.0.180/pan/pod:latest

删除镜像

1.用到标签删除镜像

  docker rmi命令能够去除镜像,命令格式为docker rmi IMAGE [IMAGE...],当中IMAGE可认为地点镜像的竹签大概ID。

[root@linux-node1 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
myubuntu            latest              20c44cd7596f        10 days ago         123MB
ubuntu              16.04               20c44cd7596f        10 days ago         123MB
ubuntu              latest              20c44cd7596f        10 days ago         123MB
ubuntu              14.04               d6ed29ffda6b        10 days ago         221MB
centos              latest              d123f4e55e12        3 weeks ago         197MB
[root@linux-node1 ~]# docker rmi myubuntu:latest 
Untagged: myubuntu:latest
[root@linux-node1 ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
ubuntu              16.04               20c44cd7596f        10 days ago         123MB
ubuntu              latest              20c44cd7596f        10 days ago         123MB
ubuntu              14.04               d6ed29ffda6b        10 days ago         221MB
centos              latest              d123f4e55e12        3 weeks ago         197MB
[root@linux-node1 ~]#

4.移除镜像

docker rmi xxxxxxxxxxxx
docker rmi jasperxu/alpine
docker rmi jasperxu/alpine:v3

移除镜像前须要移除信任于该镜像的保有容器使用docker rm

 

寻觅镜像

从docker官方镜像饭馆寻找镜像

docker search [OPTIONS] TERM

OPTIONS:

--automated :只体现自动创制的镜像,私下认可值为fasle

--filter,-f :展现过滤后的探究结果

--limit :显示的最大搜索结果,暗中认可值为25

--no-trunc : 突显完整的镜像描述,默许值为fasle

--stars :列出收藏数相当的大于内定值的镜像,暗中同意值为0

搜索ubuntu镜像

[root@docker ~]# docker search ubuntu
NAME                                         DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
ubuntu                                       Ubuntu is a Debian-based Linux operating s...   6198      [OK]       
rastasheep/ubuntu-sshd                       Dockerized SSH service, built on top of of...   90                   [OK]
ubuntu-upstart                               Upstart is an event-based replacement for ...   74        [OK]       
ubuntu-debootstrap                           debootstrap --variant=minbase --components...   30        [OK]       
torusware/speedus-ubuntu                     Always updated official Ubuntu docker imag...   28                   [OK]
nuagebec/ubuntu                              Simple always updated Ubuntu docker images...   22                   [OK]
nickistre/ubuntu-lamp                        LAMP server on Ubuntu                           20                   [OK]
solita/ubuntu-systemd                        Ubuntu + systemd                                8                    [OK]
nimmis/ubuntu                                This is a docker images different LTS vers...   7                    [OK]
darksheer/ubuntu                             Base Ubuntu Image -- Updated hourly             3                    [OK]
vcatechnology/ubuntu                         A Ubuntu image that is updated daily            1                    [OK]
webhippie/ubuntu                             Docker images for ubuntu                        1                    [OK]
jordi/ubuntu                                 Ubuntu Base Image                               1                    [OK]
admiringworm/ubuntu                          Base ubuntu images based on the official u...   1                    [OK]
konstruktoid/ubuntu                          Ubuntu base image                               0                    [OK]
forumi0721ubuntuaarch64/ubuntu-aarch64-dev   ubuntu-aarch64-dev                              0                    [OK]
labengine/ubuntu                             Images base ubuntu                              0                    [OK]
forumi0721ubuntuarmhf/ubuntu-armhf-dev       ubuntu-armhf-dev                                0                    [OK]
forumi0721ubuntux64/ubuntu-x64-dev-armbian   ubuntu-x64-dev-armbian                          0                    [OK]
forumi0721ubuntux64/ubuntu-x64-dev-android   ubuntu-x64-dev-android                          0                    [OK]
teamrock/ubuntu                              TeamRock's Ubuntu image configured with AW...   0                    [OK]
smartentry/ubuntu                            ubuntu with smartentry                          0                    [OK]
datenbetrieb/ubuntu                          custom flavor of the official ubuntu base ...   0                    [OK]
lynxtp/ubuntu                                https://github.com/lynxtp/docker-ubuntu         0                    [OK]
forumi0721ubuntux64/ubuntu-x64-dev           ubuntu-x64-dev                                  0                    [OK]

找出busybox官方镜像。并且stars数不菲于3的镜像

[root@docker ~]# docker search --filter "is-official=true" --filter "stars=3" busybox
NAME      DESCRIPTION           STARS     OFFICIAL   AUTOMATED
busybox   Busybox base image.   1044      [OK]       

依赖本地模板导入

要平素导入多少个镜像,可以从OpenVZ下载,然后用docker import导入

少年老成旦下载了ubuntu-14.04-x86-minimal.tar.gz压缩包,那么可用以下命令导入:

cat ubuntu-14.04-x86-minimal.tar.gz | docker import - ubuntu:14.04

5、创造镜像

  创立镜像有三种办法:基于本来就有镜像的容器创设、基于本地模板导入、基于Dockerfile创立。

行使build来创设镜像

docker build -t jasperxu/alpine:v3 .

  • -t 饭馆名称 jasperxu/alpine,jasperxu/alpine:v3,扶助三个docker build -t jasperxu/alpine:v3 -t jasperxu/aaa .
  • . Dockerfile文件所在路线(当前目录),假如在上一流目录可使用./alpine

本文由必威发布于必威-操作系统,转载请注明出处:是docker容器运行的前提必威,默认值为fasle

相关阅读