zoukankan      html  css  js  c++  java
  • docker容器登录,退出等操作命令

    1. Install Docker and Nvidia-Docker
        Docker: https://docs.docker.com/install/
        Nvidia-Docker: https://github.com/NVIDIA/nvidia-docker
    
    1.1 Install the repository
    
    Update the apt package index:
    
    $ sudo apt-get update
    Install packages to allow apt to use a repository over HTTPS:
    
    $ sudo apt-get install 
        apt-transport-https 
        ca-certificates 
        curl 
        gnupg-agent 
        software-properties-common
    Add Docker’s official GPG key:
    
    $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
    
    Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, 
    by searching for the last 8 characters of the fingerprint.
    
    $ sudo apt-key fingerprint 0EBFCD88
        
    pub   rsa4096 2017-02-22 [SCEA]
          9DC8 5822 9FC7 DD38 854A  E2D8 8D81 803C 0EBF CD88
    uid           [ unknown] Docker Release (CE deb) <docker@docker.com>
    sub   rsa4096 2017-02-22 [S]
    Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below. Learn about nightly and test channels.
    
    Note: The lsb_release -cs sub-command below returns the name of your Ubuntu distribution, such as xenial. Sometimes, 
    in a distribution like Linux Mint, you might need to change $(lsb_release -cs) to your parent Ubuntu distribution. 
    For example, if you are using Linux Mint Tessa, you could use bionic. Docker does not offer any guarantees on untested and unsupported Ubuntu distributions.
    
    $ sudo add-apt-repository 
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu 
       $(lsb_release -cs) 
       stable"
    
    1.2 Install Docker  INSTALL DOCKER ENGINE - COMMUNITY
        Update the apt package index.
    
    $ sudo apt-get update
    $ sudo apt-get install docker-ce docker-ce-cli containerd.io
    
    To install a specific version of Docker Engine - Community, list the available versions in the repo, then select and install:
    
    a. List the versions available in your repo:
    
    $ apt-cache madison docker-ce
    
      docker-ce | 5:18.09.1~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 5:18.09.0~3-0~ubuntu-xenial | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.1~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      docker-ce | 18.06.0~ce~3-0~ubuntu       | https://download.docker.com/linux/ubuntu  xenial/stable amd64 Packages
      
    b. Install a specific version using the version string from the second column, for example, 5:18.09.1~3-0~ubuntu-xenial.
    
    $ sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
    
    sudo apt-get install docker-ce=5:18.09.1~3-0~ubuntu-xenial
    sudo apt-get install docker-ce-cli=5:18.09.1~3-0~ubuntu-xenial
    sudo apt-get install containerd.io
    
    Verify that Docker Engine - Community is installed correctly by running the hello-world image.
    
    $ sudo docker run hello-world
    $sudo docker ps -a
    
    2, Install NVIDIA Container Toolkit
    Ubuntu 16.04/18.04, Debian Jessie/Stretch/Buster
    # Add the package repositories
    $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID)
    $ curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add -
    $ curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list
    
    $ sudo apt-get update && sudo apt-get install -y nvidia-container-toolkit
    $ sudo systemctl restart docker
    
    
    3, Pull Image
    sudo docker pull ultralytics/yolov3:v0
    
    4, Run Container
    sudo nvidia-docker run --ipc=host -it ultralytics/yolov3:v0
    sudo nvidia-docker run --ipc=host -it -v "$(pwd)"/yolov3-master:/usr/src/yolov3 ultralytics/yolov3:v0
    
    
    5, Docker commands
    sudo systemctl restart docker
    5.1.获取容器id
        docker ps
        其中container id就是容器id
    
    5.2.进入容器
        docker-enter +容器id
    
    5.3.退出容器
        ctrl+d可以直接退出容器
    5.4.重启容器
        docker restart +容器id
    
    5.5. 停止容器
        docker stop [docker-id]
        docker rm [docker-id]
    =====================================================
    6. docker启动命令,docker重启命令,docker关闭命令
     
    启动docker守护进程        systemctl start docker
    守护进程重启               sudo systemctl daemon-reload
    重启docker服务               systemctl restart  docker
    重启docker服务              sudo service docker restart
    关闭docker               service docker stop   
    关闭docker                  systemctl stop docker
    
    ssh -i aws-beijing-keypairpem.pem -N -f -L 8888:localhost:8888 ubuntu@52.81.36.78
    
    ssh -i "aws-Singapore-keypair.pem" ubuntu@ec2-13-229-239-103.ap-southeast-1.compute.amazonaws.com
    
    sudo systemctl restart docker
    
    sudo nvidia-docker run --ipc=host -it ultralytics/yolov3:v0
    sudo nvidia-docker run --ipc=host -it -v "$(pwd)"/yolov3-master/:/home/ubuntu/yolov3 ultralytics/yolov3:v0
  • 相关阅读:
    Oracle基础(五) 权限管理
    Oracle基础(四) 用户管理
    Oracle基础 PL-SQL编程基础(4) 异常处理
    Oracle基础 PL-SQL编程基础(1) 变量和常量
    bash: ifconfig: command not found 问题解决
    chrome innerHTML赋值
    IE下设置body{overflow:hidden;}失效Bug
    EXCEL保存提示“隐私问题警告:此文档中包含宏……”解决办法
    启用SQL Server 2008的专用管理员连接(DAC)
    CSS3 弹性盒模型 box-flex
  • 原文地址:https://www.cnblogs.com/cloudrivers/p/12232961.html
Copyright © 2011-2022 走看看