Docker in Ubuntu20.04

XianxinMao XianxinMao 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

docker install

Uninstall old versions

Older versions of Docker were called docker, docker.io, or docker-engine. If these are installed, uninstall them:

sudo apt-get remove docker docker-engine docker.io containerd runc

Install using the repository

Before you install Docker Engine for the first time on a new host machine, you need to set up the Docker repository. Afterward, you can install and update Docker from the repository.

Set up the repository

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

sudo apt-get update
​
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
  1. Add Docker’s official GPG key:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
  1. 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.

echo \
  "deb [arch=amd64 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

  1. 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:

sudo apt-get update
​
sudo apt-get install docker-ce docker-ce-cli containerd.io
  1. Verify that Docker Engine is installed correctly by running the hello-world image.

sudo docker run hello-world

nvidia-docker install

Setting up Docker

Docker-CE on Ubuntu can be setup using Docker’s official convenience script:

curl https://get.docker.com | sh \
  && sudo systemctl --now enable docker

Setting up NVIDIA Container Toolkit

Setup the stable repository and the GPG key:

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

Install the nvidia-docker2 package (and dependencies) after updating the package listing:

sudo apt-get update
​
sudo apt-get install -y nvidia-docker2

Restart the Docker daemon to complete the installation after setting the default runtime:

sudo systemctl restart docker

At this point, a working setup can be tested by running a base CUDA container:

sudo docker run --rm --gpus all nvidia/cuda:11.0-base nvidia-smi

docker command

HOW TO CREATE A DOCKER IMAGE FROM A CONTAINER

The Docker create command will create a new container for us from the command line:

sudo docker create --name nginx_base -p 80:80 nginx:alpine

Inspect Images

sudo docker images -a

Inspect Containers

sudo docker ps -a

We will use the docker cp command to copy this file onto the running container

sudo docker cp index.html nginx_base:/usr/share/nginx/html/index.html

Create an Image From a Container

sudo docker commit nginx_base hi_mom_nginx

python install

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get update
sudo apt-get install python3.6

Change the Python3 default version in Ubuntu

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
​
sudo update-alternatives --config python

python3-pip install

sudo apt install python3-pip
echo "alias pip=pip3" >> ~/.bash_aliases
source ~/.bash_aliases
alias pip='python3.6 -m pip'
pip install --upgrade pip
...全文

相关推荐

ubuntu20.04 LTS安装docker的方法步骤

主要介绍了ubuntu20.04 LTS安装docker的方法步骤,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

weixin_38529123

Windows10安装WSL2 Ubuntu20.04并设置docker环境的方法

主要介绍了Windows10安装WSL2 Ubuntu20.04并设置docker环境的方法,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧

weixin_38551431

docker-ubuntu2004:Docker Ubuntu 20.04基础映像

Ubuntu 20.04基础映像 Ubuntu 20.04 Docker基础映像能够测试剧本和Ansible角色,就像使用systemd的操作系统一样。 标签 latest :最新的稳定版本。 XYZ :与标签XYZ相关的确切版本 develop :当前正在测试的版本。 main :最新的beta版本。 nightly :最新的每晚版本。 如何建造 该图像在GitHub上的每一天建成,任何时间提交是push或release制成。 但是,如果您需要在本地自行构建映像,请执行以下操作: 。 cd进入该目录。 运行docker build -t localhost/ubuntu2004:test . 如何使用 。 从GitHub容器注册表中docker pull ghcr.io/pandemonium1986/ubuntu2004:nightly此映像: docker pul

莊謙

Ubuntu20.04离线部署nvidia-docker

本资源提供了Ubuntu20.04系统离线部署nvidia-docker的安装包和安装流程,对于离线配置算法训练环境非常有用。

绿色背影

Ubuntu20.04安装Docker

Ubuntu20.04安装Docker方式一方式二 方式一 安装简单,版本比较老 sudo snap install docker 方式二 卸载可能已经安装的旧版本 sudo apt remove docker docker-engine docker.io containerd runc 升级 apk 工具以支持 https 类型库 sudo apt update sudo apt upgrade sudo apt install \ apt-transport-https \

JiangHaoSpring
评论
收藏 已收藏
分享
返回顶部