Ubuntu上安装Docker步骤:
- 更新软件包列表:
bash
sudo apt update
- 安装一些必要的软件包,以便您可以通过HTTPS使用存储库:
bash
sudo apt install apt-transport-https ca-certificates curl software-properties-common
- 添加Docker的官方GPG密钥:
bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
- 添加Docker存储库:
bash
echo "deb [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
- 再次更新软件包列表以包括Docker存储库:
bash
sudo apt update
- 安装Docker:
bash
sudo apt install docker-ce
- 启动Docker服务并设置其在系统启动时自动启动:
bash
sudo systemctl start docker
sudo systemctl enable docker
- 确认Docker是否正确安装:
sudo docker --version
注意,要在不使用sudo的情况下运行docker命令,您可以将当前用户添加到docker组中,然后注销并重新登录:
bash
sudo usermod -aG docker $USER
然后注销并重新登录以应用更改。这将允许您以当前用户的身份运行docker命令,而不需要sudo权限。
bash
docker run -it 6a73b89c386f /bin/bash
Docker容器映射:
bash
docker run -it -u ma-user --device=/dev/davinci0 --device=/dev/davinci1 --device=/dev/davinci2 --device=/dev/davinci3 --device=/dev/davinci4 --device=/dev/davinci5 --device=/dev/davinci6 --device=/dev/davinci7 --device=/dev/davinci_manager --device=/dev/devmm_svm --device=/dev/hisi_hdc -v /usr/local/Ascend/:/usr/local/Ascend/ -v /usr/local/Ascend/add-ons/:/usr/local/Ascend/add-ons/ -v /usr/local/bin/npu-smi:/usr/local/bin/npu-smi -v /usr/local/sbin/npu-smi:/usr/local/sbin/npu-smi --entrypoint=/bin/bash 240b30f47a7f
华为200DK部署Docker: