docker 入門

docker基礎命令

Usage:
docker [OPTIONS] COMMAND [arg...]
docker daemon [ --help | ... ]
docker [ --help | -v | --version ]
A
self-sufficient runtime for containers.

Options:
    --config=~/.docker              Location of client config files #客戶端配置文件的位置
    -D, --debug=false               Enable debug mode #啓用 Debug 調試模式
    -H, --host=[]                   Daemon socket(s) to connect to #守護進程的套接字(Socket)鏈接
    -h, --help=false                Print usage #打印使用
    -l, --log-level=info            Set the logging level #設置日誌級別
    --tls=false Use TLS;            implied by--tlsverify #
    --tlscacert=~/.docker/ca.pem    Trust certs signed only by this CA #信任證書籤名 CA
    --tlscert=~/.docker/cert.pem    Path to TLS certificate file #TLS 證書文件路徑
    --tlskey=~/.docker/key.pem      Path to TLS key file #TLS 密鑰文件路徑
    --tlsverify=false               Use TLS and verify the remote #使用 TLS 驗證遠程
    -v, --version=false             Print version information and quit #打印版本信息並退出

Commands:
    attach      Attach to a running container #當前 shell 下 attach 鏈接指定運行鏡像
    build       Build an image from a Dockerfile #經過 Dockerfile 定製鏡像
    commit      Create a new image from a container’s changes #提交當前容器爲新的鏡像
    cp          Copy files/folders from a container to a HOSTDIR or to STDOUT #從容器中拷貝指定文件或者目錄到宿主機中
    create      Create a new container #建立一個新的容器,同 run 但不啓動容器
    diff        Inspect changes on a container’s filesystem #查看 docker 容器變化
    events      Get real time events from the server#從 docker 服務獲取容器實時事件
    exec        Run a command in a running container#在已存在的容器上運行命令
    export      Export a container’s filesystem as a tar archive #導出容器的內容流做爲一個 tar 歸檔文件(對應 import)
    history     Show the history of an image #展現一個鏡像造成歷史
    images      List images #列出系統當前鏡像
    import      Import the contents from a tarball to create a filesystem image #從 tar 包中的內容建立一個新的文件系統映像(對應 export)
    info        Display system-wide information #顯示系統相關信息
    inspect     Return low-level information on a container or image #查看容器詳細信息
    kill        Kill a running container #kill 指定 docker 容器
    load        Load an image from a tar archive or STDIN #從一個 tar 包中加載一個鏡像(對應 save)
    login       Register or log in to a Docker registry#註冊或者登錄一個 docker 源服務器
    logout      Log out from a Docker registry #從當前 Docker registry 退出
    logs        Fetch the logs of a container #輸出當前容器日誌信息
    pause       Pause all processes within a container#暫停容器
    port        List port mappings or a specific mapping for the CONTAINER #查看映射端口對應的容器內部源端口
    ps          List containers #列出容器列表
    pull        Pull an image or a repository from a registry #從 docker 鏡像源服務器拉取指定鏡像或者庫鏡像
    push        Push an image or a repository to a registry #推送指定鏡像或者庫鏡像至 docker 源服務器
    rename      Rename a container #重命名容器
    restart     Restart a running container #重啓運行的容器
    rm          Remove one or more containers #移除一個或者多個容器
    rmi         Remove one or more images #移除一個或多個鏡像(無容器使用該鏡像才能夠刪除,不然須要刪除相關容器才能夠繼續或者-f 強制刪除)
    run         Run a command in a new container #建立一個新的容器並運行一個命令
    save        Save an image(s) to a tar archive#保存一個鏡像爲一個 tar 包(對應 load)
    search      Search the Docker Hub for images #在 docker hub 中搜索鏡像
    start       Start one or more stopped containers#啓動容器
    stats       Display a live stream of container(s) resource usage statistics #統計容器使用資源
    stop        Stop a running container #中止容器
    tag         Tag an image into a repository #給源中鏡像打標籤
    top         Display the running processes of a container #查看容器中運行的進程信息
    unpause     Unpause all processes within a container #取消暫停容器
    version     Show the Docker version information#查看容器版本號
    wait        Block until a container stops, then print its exit code #截取容器中止時的退出狀態值

Run 'docker COMMAND --help' for more information on a command. #運行 docker 命令在幫助能夠獲取更多信息
docker search hello-docker # 搜索 hello-docker 的鏡像
docker search centos # 搜索 centos 鏡像
docker pull hello-docker # 獲取 centos 鏡像
docker run hello-world #運行一個 docker 鏡像,產生一個容器實例(也能夠經過鏡像 id 前三位運行)
docker image ls # 查看本地全部鏡像
docker images # 查看 docker 鏡像
docker image rmi hello-docker # 刪除 centos 鏡像
docker ps #列出正在運行的容器(若是建立容器中沒有進程正在運行,容器就會當即中止)
docker ps -a # 列出全部運行過的容器記錄
docker save centos > /opt/centos.tar.gz # 導出 docker 鏡像至本地
docker load < /opt/centos.tar.gz #導入本地鏡像到 docker 鏡像庫
docker stop `docker ps -aq` # 中止全部正在運行的容器
docker rm `docker ps -aq` # 一次性刪除全部容器記錄
docker rmi `docker images -aq` # 一次性刪除全部本地的鏡像記錄
複製代碼
相關文章
相關標籤/搜索