Docker01——Ubuntu上安装Docker

学习Docker之前要先安装好,下面来谈谈安装步骤,本人直接copy官网上的安装步骤,只不过将各个步骤编写成了一个Shell文件(最底下),直接执行即可,只需要注意以下地方
1.输入docker-ce的版本号

这里需要copy上面展示出的版本号,然后粘贴后按enter键
2.对于询问的地方,直接输入Y

据统计,出现确认的地方应该有两处,最后出现如下输出就表示安装好了docker容器

3.如果执行脚本文件的时候出现错误,如:

line 1: $'
': command not found


这是因为在windows的记事本之中换行符和Linux系统之中不一样导致的,解决方案:
vi编辑器或者vim打开文件,然后在命令模式下输入:

set ff=unix

然后保存即可
下面是官网的安装代码,保存到某个.sh文件中,然后执行即可

# 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
# 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-agent software-properties-common
# Add Docker’s official GPG key:
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"

# 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
# 2.To install a specific version of Docker Engine, list the available versions in the repo, then select and install:
apt-cache madison docker-ce
# 2.1 List the versions available in your repo:
read -p "Please input a docker-ce version:" VERSION_STRING
# 2.2 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
# 2.3 Verify that Docker Engine is installed correctly by running the hello-world image.
sudo docker run hello-world

参考文章

[1] Install Docker Engine on Ubuntu

原文地址:https://www.cnblogs.com/dabenhou/p/13926108.html