close

搜尋映像檔

# docker search [OPTIONS] 映像檔名

-- docker search --limit 5 映像檔名 --> 搜尋前5個映像檔

 

提取映像檔

# docker image pull [OPTIONS] 映像檔名[:TAG|@DIGEST]

# docker pull [OPTIONS] 映像檔名[:TAG|@DIGEST]

-- docker image pull --all-tags 映像檔名 --> 提取所有相關標記的映像檔

 

列出映像檔

# docker image ls

# docker images

 

啟動容器

# docker run [OPTIONS] 映像檔名 [指令] [ARG...]

# docker container run [OPTIONS] 映像檔名 [指令] [ARG...]

-- docker container run -i -t --name mycontainer 映像檔名 /bin/bash 

--> 起始一容器在交談模式中並配置一pseudo-tty,命名為mycontainer接著在容器中執行/bin/bash指令

 

建立並啟動容器

# docker container create [OPTIONS] 映像檔名 [指令] --> 回傳容器ID

-- docker container create -t -i 映像檔名 /bin/bash

# docker container start [OPTIONS] 容器ID

-- docker container start -a -i 容器ID

 

列出容器

# docker container ls [OPTIONS]

# docker ps [OPTIONS]

-- docker container ls -a --> 列出所有執行中與未執行的容器

 

檢視容器日誌檔

# docker container logs [OPTIONS] 容器ID

# docker  logs [OPTIONS] 容器ID

 

停止運行容器

# docker container stop [OPTIONS] 容器ID

# docker stop [OPTIONS] 容器ID

-- docker stop $(docker ps -q) --> 停止所有執行中容器

 

移除容器

# docker container rm [OPTIONS] 容器ID

# docker rm [OPTIONS] 容器ID

-- docker container rm -f 容器ID --> 強制移除未停止的容器

 

移除所有停止中的容器

# docker container prune [OPTIONS]

 

從容器建立映像檔

# docker container commit [OPTIONS] 容器ID [Repository名[:TAG]]

-- docker container commit --author "Rex" --message "Example commit" 容器ID Repository名

arrow
arrow
    文章標籤
    docker
    全站熱搜
    創作者介紹
    創作者 Rex 的頭像
    Rex

    Rex-Software-Blog

    Rex 發表在 痞客邦 留言(0) 人氣()