docker容器使用(docker容器命令)

一、docker客戶端docker

    1)經過docker查看客戶端的全部命令ubuntu

        [root@localhost ~]# dockerbash

        image.png

    2)深刻了解docker命令使用方法ide

        [root@localhost ~]# docker stats --helpspa

        image.png




二、容器的使用3d

    1)獲取鏡像(載入ubuntu鏡像)rest

        [root@localhost ~]# docker pull ubuntublog

    2)啓動容器,並進入該容器it

        [root@localhost ~]# docker run -it ubuntu /bin/bashclass

        image.png

            參數說明:

                -i:交互式操做

                -t:終端

                ubuntu:ubuntu鏡像

                /bin/bash:放在鏡像名後的是命令,這裏咱們但願有一個交互式的Shell,所以用的是/bin/bash


                退出終端使用exit命令


    3)查看全部容器

        [root@localhost ~]# docker ps -a

    4)啓動已經中止的容器

        [root@localhost ~]# docker start 16f91abb561d

    5)docker容器後臺運行,使用-d指定容器的運行模式

        [root@localhost ~]# docker run -itd --name ubuntu-test ubuntu /bin/bash

    6)中止容器

        [root@localhost ~]# docker stop cbeab6605102

    7)重啓容器

        [root@localhost ~]# docker restart cbeab6605102

    8)後臺啓動時進入容器時,使用attach命令

        [root@localhost ~]# docker attach f4c1ed1987e4

        image.png


        注意:使用attach進入容器後,再退出這個容器,會致使容器的中止

    9)使用exec進入後臺運行的容器,從容器中退出,不會致使容器的中止

        [root@localhost ~]# docker exec -it d9d6240dffe1 /bin/bash

        image.png




三、容器的導入導出

    1)導出容器

        [root@localhost ~]# docker export d9d6240dffe1 > /tmp/ubuntu.tar

        image.png

    2)導入容器快照(從快照文件中導入爲鏡像,如下實例將快照文件ubuntu.tar導入到鏡像test/ubuntu:v1)

        [root@localhost ~]# docker import /tmp/ubuntu.tar test/ubuntu:v1




四、刪除容器

    1)刪除一個容器

        [root@localhost ~]# docker rm -f d9d6240dffe1

    2)刪除全部容器

        [root@localhost ~]# docker rm -f $(docker ps -aq)

相關文章
相關標籤/搜索