一、开篇基于Ubuntu的docker环境搭建
1、准备一台Ubuntu
首先要准备一台Ubuntu的Linux机器,可以是阿里云腾讯云等云平台的,也可以是虚拟机虚出来的机器,当然也可以是物理机,我这里准备了家里一台PVE机器上虚出来的一台Ubuntu22.04。
开启ssh远程连接,这样就可以像上图一样,通过电脑ssh到远程的机器上了。
#升级安装包
apt update
#进行安装包的更新
apt upgrade
#安装ssh
apt install openssh-server
#可选项,为了连接别的ssh-server
apt install openssh-client
#启动ssh服务
service ssh start
切换到root用户
#切换到root用户
sudu su -
2、安装前提依赖
#获取软件最新源
sudo apt-get update
apt-get install ca-certificates curl gnupg lsb-release
3、安装GPG证书
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
4、写入软件源信息
add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
5、安装docker
Docker 的旧版本被称为 docker,docker.io 或 docker-engine。当前称为 Docker Engine-Community 软件包 docker-ce。
apt-get install docker-ce docker-ce-cli containerd.io
6、启动Docker服务
#启动Docker服务
service docker start
7、运行hello-world镜像
docker run hello-world
当出现如下字样时,表示正确安全并运行了hello-world
Hello from Docker!
This message shows that your installation appears to be working correctly.
docker环境搭建执行的全部过程如下: