美文网首页
小鲸鱼docker常用命令

小鲸鱼docker常用命令

作者: 蕴重Liu | 来源:发表于2019-07-28 22:20 被阅读0次
    • 创建镜像
    --拉取debian镜像
    docker pull debian
    
    
    • 运行容器
    --运行并别名为debian1
    --create + start
    docker run --name debian1 -it debian
    --启动已装好的镜像并进入交互cli界面
    docker run -i --tty  [IMAGE_ID]  bash
    --创建并绑定端口
    # 把容器的3001端口绑定到本机的2701,
    docker run -itd -p 3001:2701 --name hello [image_name]
    
    
    • 查看容器操作
    --查看所有的已装好的容器
    docker container ls --all
    --查看停止状态的容器
    docker 
    --查看所有的镜像
    docker images
    
    • 进入处于运行状态的容器
    docker container attach [container_id]
    
    • 删除容器
    --根据容器id删除
    docker container rm [container_id]
    --删除所有处于停止状态的容器
    # 注意删除前要停止
    docker rm $(docker ps -a -f status=exited -q)
    
    • 若不能直接通过apt命令安装,则apt-get update
    root@1a4c57cbb604:/# apt-get update 
    Get:1 http://cdn-fastly.deb.debian.org/debian buster InRelease [118 kB]                               
    Get:3 http://security-cdn.debian.org/debian-security buster/updates InRelease [39.1 kB]               
    Get:4 http://security-cdn.debian.org/debian-security buster/updates/main amd64 Packages [50.9 kB]                                                                                                                                                                            
    Get:2 http://cdn-fastly.deb.debian.org/debian buster-updates InRelease [46.8 kB]                                                                                                                                                                                             
    Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 Packages [7897 kB]                                                                                                                                                                                           
    Fetched 8152 kB in 1min 16s (107 kB/s)                                                                                                                                                                                                                                       
    Reading package lists... Done
    root@1a4c57cbb604:/# apt-get install wget
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    The following additional packages will be installed:
      ca-certificates libpcre2-8-0 libpsl5 libssl1.1 openssl publicsuffix
    The following NEW packages will be installed:
      ca-certificates libpcre2-8-0 libpsl5 libssl1.1 openssl publicsuffix wget
    0 upgraded, 7 newly installed, 0 to remove and 0 not upgraded.
    Need to get 3819 kB of archives.
    After this operation, 10.4 MB of additional disk space will be used.
    Do you want to continue? [Y/n] y
    Get:1 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libpcre2-8-0 amd64 10.32-5 [213 kB]
    Get:2 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libpsl5 amd64 0.20.2-2 [53.7 kB]
    Get:3 http://cdn-fastly.deb.debian.org/debian buster/main amd64 wget amd64 1.20.1-1.1 [902 kB]
    Get:4 http://cdn-fastly.deb.debian.org/debian buster/main amd64 libssl1.1 amd64 1.1.1c-1 [1535 kB]
    Get:5 http://cdn-fastly.deb.debian.org/debian buster/main amd64 openssl amd64 1.1.1c-1 [842 kB]                                                                                                                                                                              
    Get:6 http://cdn-fastly.deb.debian.org/debian buster/main amd64 ca-certificates all 20190110 [157 kB]                                                                                                                                                                        
    Get:7 http://cdn-fastly.deb.debian.org/debian buster/main amd64 publicsuffix all 20190415.1030-1 [116 kB]                                                                                                                                                                    
    Fetched 3819 kB in 55s (69.6 kB/s)                                                                                                                                                                                                                                           
    debconf: delaying package configuration, since apt-utils is not installed
    Selecting previously unselected package libpcre2-8-0:amd64.
    (Reading database ... 6674 files and directories currently installed.)
    Preparing to unpack .../0-libpcre2-8-0_10.32-5_amd64.deb ...
    Unpacking libpcre2-8-0:amd64 (10.32-5) ...
    Selecting previously unselected package libpsl5:amd64.
    Preparing to unpack .../1-libpsl5_0.20.2-2_amd64.deb ...
    Unpacking libpsl5:amd64 (0.20.2-2) ...
    Selecting previously unselected package wget.
    Preparing to unpack .../2-wget_1.20.1-1.1_amd64.deb ...
    Unpacking wget (1.20.1-1.1) ...
    Selecting previously unselected package libssl1.1:amd64.
    Preparing to unpack .../3-libssl1.1_1.1.1c-1_amd64.deb ...
    Unpacking libssl1.1:amd64 (1.1.1c-1) ...
    Selecting previously unselected package openssl.
    Preparing to unpack .../4-openssl_1.1.1c-1_amd64.deb ...
    Unpacking openssl (1.1.1c-1) ...
    Selecting previously unselected package ca-certificates.
    Preparing to unpack .../5-ca-certificates_20190110_all.deb ...
    Unpacking ca-certificates (20190110) ...
    Selecting previously unselected package publicsuffix.
    Preparing to unpack .../6-publicsuffix_20190415.1030-1_all.deb ...
    Unpacking publicsuffix (20190415.1030-1) ...
    Setting up libpsl5:amd64 (0.20.2-2) ...
    Setting up libssl1.1:amd64 (1.1.1c-1) ...
    debconf: unable to initialize frontend: Dialog
    debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
    debconf: falling back to frontend: Teletype
    Setting up libpcre2-8-0:amd64 (10.32-5) ...
    Setting up openssl (1.1.1c-1) ...
    Setting up publicsuffix (20190415.1030-1) ...
    Setting up wget (1.20.1-1.1) ...
    Setting up ca-certificates (20190110) ...
    debconf: unable to initialize frontend: Dialog
    debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
    debconf: falling back to frontend: Readline
    debconf: unable to initialize frontend: Readline
    debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.28.1 /usr/local/share/perl/5.28.1 /usr/lib/x86_64-linux-gnu/perl5/5.28 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.28 /usr/share/perl/5.28 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
    debconf: falling back to frontend: Teletype
    Updating certificates in /etc/ssl/certs...
    128 added, 0 removed; done.
    Processing triggers for libc-bin (2.28-10) ...
    Processing triggers for ca-certificates (20190110) ...
    Updating certificates in /etc/ssl/certs...
    0 added, 0 removed; done.
    Running hooks in /etc/ca-certificates/update.d...
    done.
    root@1a4c57cbb604:/# 
    

    相关文章

      网友评论

          本文标题:小鲸鱼docker常用命令

          本文链接:https://www.haomeiwen.com/subject/gxcmrctx.html