简介
Docker是一个 开源 的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的 镜像 中,然后发布到任何流行的Linux或Windows机器上,也可以实现 虚拟化 。容器是完全使用沙箱机制,相互之间不会有任何接口。
配置流程
Ubuntu操作系统
1. 准备环境
准备实例
从华为云官网购买鲲鹏 云服务 ECS实例
安装依赖包
执行以下命令安装依赖包。
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
2.执行安装
方式一:通过软件仓库安装
1) 老版本的Docker的命名为“ docker ”、“docker.io” 或 “docker-engine”,如果安装了这些版本,需要先卸载掉。
保存在“/var/lib/docker”/中的内容,包括图片、磁盘和网络配置等都会保留下来。
sudo apt-get remove docker docker-engine docker.io containerd runc
2)添加Docker官方GPG key。
curl -fsSL https://download.docker.com/linux/ ubuntu /gpg | sudo apt-key add -
3)设置Docker CE软件仓库版本为arm64。
sudo add-apt-repository \
"deb [arch=arm64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
4)安装docker-ce软件。
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
如果需要安装指定版本的docker-ce,可以执行以下命令:
sudo apt-get install docker-ce=<VERSION_STRING> docker-ce-cli=<VERSION_STRING> containerd.io
方式二:下载软件包进行安装
1)通过https://download.docker.com/linux/ubuntu/dists/bionic/pool/stable/arm64/,下载指定版本的软件包。
2)执行命令安装软件包及依赖。
“package.deb”为下载的软件包。
sudo dpkg -i /path/to/package.deb
3. 启动软件
1)启动docker。
sudo systemctl start docker
2)使用一个hello-world镜像验证docker是否正常。
sudo docker run hello-world
回显内容如下:
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
3b4173355427: Pull complete
Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8
Status: Downloaded newer image for hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm64v8)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash
Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/
For more examples and ideas, visit:
https://docs.docker.com/get-started/
CentOS操作系统
1.准备环境
准备实例
从华为云官网购买鲲鹏云服务ECS实例
安装依赖包
执行以下命令安装依赖包。
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
2.执行安装
方式一:使用软件仓库安装
1)老版本的docker的命名为“docker”或 “docker-engine”,如果安装了这些版本,需要先卸载掉。
保存在“/var/lib/docker/”中的内容,包括图片、磁盘和网络配置等都会保留下来。
sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate
2)配置软件仓库。
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
3) 安装docker-ce。
sudo yum install docker-ce docker-ce-cli containerd.io
这个命令总是会安装最新版本的docker-ce,如果需要安装指定版本的可以参考下面的操作:
sudo yum install docker-ce-<VERSION_STRING> docker-ce-cli-<VERSION_STRING> containerd.io
方式二:下载软件包进行安装
1)通过https://download.docker.com/linux/centos/7/aarch64/stable/Packages/,下载指定版本的软件包。
2)执行命令安装软件包及依赖。
“package.rpm”为下载的软件包。
sudo yum install /path/to/package.rpm
3. 启动软件
1)启动Docker。
sudo systemctl start docker
2)使用一个hello-world镜像验证Docker是否正常。
sudo docker run hello-world
回显内容如下:
Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 3b4173355427: Pull complete Digest: sha256:41a65640635299bab090f783209c1e3a3f11934cf7756b09cb2f1e02147c6ed8 Status: Downloaded newer image for hello-world:latest Hello from Docker! This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps: 1. The Docker client contacted the Docker daemon. 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.(arm64v8) 3. The Docker daemon created a new container from that image which runs the executable that produces the output you are currently reading. 4. The Docker daemon streamed that output to the Docker client, which sent it to your terminal. To try something more ambitious, you can run an Ubuntu container with: docker run -it ubuntu bash Share images, automate workflows, and more with a free Docker ID: https://hub.docker.com/ For more examples and ideas, visit: https://docs.docker.com/get-started/