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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM