Docker学習ノート(3)-Dockerミラーと倉庫

4563 ワード

参照先:http://www.jikexueyuan.com/course/859.html http://www.jikexueyuan.com/course/876.html
ミラーとウェアハウス
ミラーの表示と削除
ミラーが格納されている場所/var/lib/docker
ミラーのリスト
docker images [OPTIONS] [REPOSITORY]

-a, –all=false Show all images (default hides intermediate images) –digests=false Show digests -f, –filter=[] Filter output based on conditions provided –help=false Print usage –no-trunc=false Don’t truncate output -q, –quiet=false Only show numeric IDs
ミラーラベルと倉庫
docker imagesを実行すると、Docker 学习笔记(三)--Docker镜像与仓库_第1张图片が表示されます.
その中でPEROSITORYは倉庫で、TAGはラベルです
ミラーの表示
docker inspect [OPTIONS] CONTAINER|IMAGE [CONTAINER|IMAGE...]

-f, –format= Format the output using the given go template –help=false Print usage –type= Return JSON for specified type, (e.g image or container)
ミラーの削除
docker rmi [OPTIONS] IMAGE [IMAGE...]

-f, –force=false Force removal of the image –help=false Print usage –no-prune=false Do not delete untagged parents
ミラーの取得とプッシュ
ミラーの検索
docker search [image]

ミラーをプル
docker pull [image]

-a, –all-tags=false
加速使用–registry-mirrorオプション1.修正:/etc/default/docker 2.追加:DOCKER_OPTIOS = “–registry-mirror=http://XXXX”
プッシュミラー
docker push 

ミラーの構築
docker commitコンテナ構築docker build Dockerfileファイル構築
docker commit [OPTIONS] CONTAINER [REPOSITORY[:TAG]]

-a, –author= Author (e.g., “John Hannibal Smith [email protected]”) -c, –change=[] Apply Dockerfile instruction to the created image –help=false Print usage -m, –message= Commit message -p, –pause=true Pause container during commit
例:
docker run -d --name test_web -p 80:80 billvsme/web nginx -g "daemon off;"

Dockerfileを使用したミラーの構築
docker build [OPTIONS] PATH | URL | -

–no-cache=false Do not use cache when building the image -q, –quiet=false Suppress the verbose output generated by -t, –tag= Repository name (and optionally a tag) for the image
例:
docker build -t ='billvsme/web' ./

ミラー構築プロセスの表示
docker history [image]

Dockerfile形式
コメント
# Comment

インストラクション
FROM
FROM <image>
FROM <image>:<tag>
      
    
           

MAINTAINER
MAINTAINER <name>
         

            

RUN
RUN <command> (shell  )
RUN echo hello
RUN ["executable", "param1", "param2"] (exec   )
RUN ["/bin/bash", "-c", "echo hellow"]

EXPOSE
        ,    docker          ,         ,    run           。

例:
#First Dockerfile
FROM ubuntu:14.04
MAINTAINER billvsme "[email protected]"
RUN apt-get update
RUN apt-get install -y nginx
EXPOSE 80

その他のコマンド
CMD
CMD command param1 param2 (shell  )
CMD ['executable', "param1", "param2"] (exec  )
CMD ['param1', 'param2'] (  ENTERYPOINT       )
RUN                 ,CMD            ,    docker run   cmd  ,CMD      

ENTERYPOINT
ENTERYPOINT command param1 param2(shell  )
ENTERYPOINT ['executable', "param1", "param2"] (exec  )
 CMD     ,ENTERYPOINT      ,     ,     docker run --entrypoint   

COPY
COPY <src> ... <desc>
COPY ["<src>"..."<dest>"] (              )

ADD
ADD  COPY    ,  ADD     tar     ,ADD src    url

VOLUME
VOLUME ["/data"]       

WORKDIR
WORKDIR /path/to/workdir
           ,  CMD、ENTERYPOINT           

ENV
ENV <key><value>
ENV <key>=<value>...
      

USER
USER uid
USER uid:gid
USER uid:group
USER nginx
 nginx     
   root

ONBUILD
ONBUILD [INSTRUCTION]
     
                   ,