Docker

Docker install

Docker Engine overview

Docker Engine is an open source containerization technology for building and containerizing your applications. Docker Engine acts as a client-server application with:

  1. A server with a long-running daemon process dockerd.

  2. APIs which specify interfaces that programs can use to talk to and instruct the Docker daemon.

  3. A command line interface (CLI) client docker.

The CLI uses Docker APIs to control or interact with the Docker daemon through scripting or direct CLI commands. Many other Docker applications use the underlying API and CLI. The daemon creates and manage Docker objects, such as images, containers, networks, and volumes.

Set up the repository

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

1
2
3
4
5
6
7
sudo apt-get update

sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release

Add Docker’s official GPG key

1
2
3
4
curl -fsSL \
https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor \
-o /usr/share/keyrings/docker-archive-keyring.gpg

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.

1
2
3
4
5
6
 echo \
"deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] \
https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

Update the apt package index, and install the latest version of Docker Engine and containerd, or go to the next step to install a specific version:

1
2
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io

验证安装,如图验证Docker

这里已经安装好Docker,可以先从docker hub拉镜像,然后启动容器,这里因为已经以前安装并使用过,就直接那一个容器作为结果演示,如图Docker镜像

可以看到有很多镜像,如图Docker容器

可以看到每个容器以及对应的镜像,如图启动镜像

启动并连接镜像,如图环境隔离

可以看到docker内外CUDA版本不一样,如图,Docker作为虚拟容器,起到了隔离环境的效果,并且docker的隔离比conda更为彻底,又不需要重新安装虚拟机那么麻烦。


本博客所有文章除特别声明外,均采用 CC BY-SA 4.0 协议 ,转载请注明出处!