Doceker常用命令

  • docker version

    顯示當(dāng)前客戶端和服務(wù)端的版本信息

  • docker info

    顯示容器,鏡像等的數(shù)量,以及宿主機(jī)的一些信息

  • docker --help

    attach Attach to a running container
    build Build an image from a Dockerfile
    commit Create a new image from a container's changes
    cp Copy files/folders between a container and the local filesystem
    create Create a new container
    diff Inspect changes on a container's filesystem
    events Get real time events from the server
    exec Run a command in a running container
    export Export a container's filesystem as a tar archive
    history Show the history of an image
    images List images
    import Import the contents from a tarball to create a filesystem image
    info Display system-wide information
    inspect Return low-level information on Docker objects
    kill Kill one or more running containers
    load Load an image from a tar archive or STDIN
    login Log in to a Docker registry
    logout Log out from a Docker registry
    logs Fetch the logs of a container
    pause Pause all processes within one or more containers
    port List port mappings or a specific mapping for the container
    ps List containers
    pull Pull an image or a repository from a registry
    push Push an image or a repository to a registry
    rename Rename a container
    restart Restart one or more containers
    rm Remove one or more containers
    rmi Remove one or more images
    run Run a command in a new container
    save Save one or more images to a tar archive (streamed to STDOUT by default)
    search Search the Docker Hub for images
    start Start one or more stopped containers
    stats Display a live stream of container(s) resource usage statistics
    stop Stop one or more running containers
    tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
    top Display the running processes of a container
    unpause Unpause all processes within one or more containers
    update Update configuration of one or more containers
    version Show the Docker version information
    wait Block until one or more containers stop, then print their exit codes

  • docker images

    -a 列出本地所有鏡像

    -q 只列出鏡像id

    --digests 列出摘要

    --no-trunc 顯示完整信息

  • docker search

    查找指定的鏡像

    -s [數(shù)量] 只顯示點(diǎn)贊數(shù)超過(guò)指定數(shù)量的鏡像,已被廢棄,建議使用--filter=starts=數(shù)量替代

    --no-trunc 不省略介紹信息

  • docker pull

    從倉(cāng)庫(kù)拉取某個(gè)鏡像

    eg:docker pull tomcat 等價(jià)于 docker pull tomcat:latest

  • docker rmi

    刪除某個(gè)鏡像

    刪除時(shí)需要停止并且刪除依賴于此鏡像的容器

    -f 參數(shù) 強(qiáng)制刪除。

    eg:

    刪除一個(gè):docker rmi -f hello-world

    刪除多個(gè):docker rmi -f hello-world nginx

    刪除全部:docker rmi -f $(docker images -qa)

  • docker run
    image-20200504141333769.png

創(chuàng)建并啟動(dòng)一個(gè)容器

  • docker ps

    列出正在運(yùn)行的容器

    -l 上一個(gè)容器

    -n 上面若干個(gè)容器

    -a 所有的,包括已經(jīng)停止的

    -q 只顯示容器編號(hào)

  • exit

    在交互模式中退出容器, 容器停止

  • ctrl+p+q

    在交互模式中退出容器, 容器停止

  • docker start

    啟動(dòng)一個(gè)容器,根據(jù)id或者名字

  • docker restart

    重啟一個(gè)容器,根據(jù)id或者名字

  • docker stop

    停止一個(gè)容器, 根據(jù)id或者名字

  • docker kill

    強(qiáng)制停止一個(gè)容器, 根據(jù)id或者名字

  • docker rm

    刪除一個(gè)容器, 根據(jù)id或者名字

    -f 強(qiáng)制刪除

    docker rm $(docker ps -aq)

    docker rm -f $(docker ps -aq)

  • docker top

    查看docker容器的進(jìn)程

  • docker logs

    查看docker的log

    -t 加入時(shí)間戳

    -f 持續(xù)輸出

    --tail 查看最后幾行

  • docker inspect

    顯示容器內(nèi)部細(xì)節(jié)

  • docker attach

    進(jìn)入某個(gè)容器的交互界面

    eg :docker attach 64e8705a29d4

  • docker exec

    docker exec -t 64e8705a29d4 ls -l /tmp

    直接執(zhí)行命令,并把結(jié)果返回宿主機(jī)

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容