docker 的产生:
docker 的历史:
目标:
docker镜像就好比是一个模板,可以通过这个模板来创建容器服务,tomcat像===>run ==> tomcat01 容器(提供服务器)通过这个镜像可以创建多个容器( 最终服务运行或者项目运行就是在容器中的)。
Docker利用容器技术,独立运行一个或者一个组应用,通过镜像来创建的。 启动,停止,删除,基本命令 ! 目前就可以把这个容器理解为就是一个简易的linux系统
仓库就是存放镜像的地方 ! 仓库分为公有仓库和私有仓库! Docker Hub( 默认是国外的 ) 阿里云....都有容器服务器( 配置镜像加速 ! )
这里直接使用 华为云 的试用服务器- -
shell# 系统内核 4.18
[root@hecs-152658 ~]# uname -r
4.18.0-348.7.1.el8_5.x86_64
# 系统版本
[root@hecs-152658 ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="8 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Linux 8 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-8"
CENTOS_MANTISBT_PROJECT_VERSION="8"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="8"
帮助文档:https://docs.docker.com/engine/install/
shell[root@hecs-152658 ~]# yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
No match for argument: docker
No match for argument: docker-client
No match for argument: docker-client-latest
No match for argument: docker-common
No match for argument: docker-latest
No match for argument: docker-latest-logrotate
No match for argument: docker-logrotate
No match for argument: docker-engine
No packages marked for removal.
Dependencies resolved.
Nothing to do.
Complete!
shell[root@hecs-152658 ~]# sudo yum install -y yum-utils Last metadata expiration check: 0:05:41 ago on Fri 28 Jul 2021 04:54:36 PM CST. Package yum-utils-4.0.21-3.el8.noarch is already installed. Dependencies resolved. Nothing to do. Complete!
shell# 默认是国外的,设置程阿里云的仓库
# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
[root@hecs-152658 ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
shell# 如果是 centos7 需要 yum makecache fast
[root@hecs-152658 ~]# yum makecache
CentOS-8 - AppStream 52 kB/s | 4.3 kB 00:00
CentOS-8 - Base 44 kB/s | 3.9 kB 00:00
CentOS-8 - Extras 19 kB/s | 1.5 kB 00:00
Copr repo for caddy owned by @caddy 1.5 kB/s | 3.3 kB 00:02
Docker CE Stable - x86_64 66 kB/s | 3.5 kB 00:00
Extra Packages for Enterprise Linux 8 - x86_64 9.3 kB/s | 4.7 kB 00:00
Extra Packages for Enterprise Linux Modular 8 - 4.1 kB/s | 3.0 kB 00:00
Metadata cache created.
shell# yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
[root@hecs-152658 ~]# yum install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
省略...
Complete!
shell[root@hecs-152658 ~]# sudo systemctl start docker [root@hecs-152658 ~]# docker -v Docker version 24.0.5, build ced0996
shell[root@hecs-152658 ~]# sudo docker run hello-world
# 本地镜像获取(获取不到)
Unable to find image 'hello-world:latest' locally
# 拉取远程镜像
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598
Status: Downloaded newer image for hello-world:latest
# 运行 hello-world
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.
(amd64)
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/
shell[root@hecs-152658 ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest 9c7a54a9a43c 2 months ago 13.3kB
shellsudo yum remove docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-ce-rootless-extras
shellsudo rm -rf /var/lib/docker sudo rm -rf /var/lib/containerd
本文作者:Yui_HTT
本文链接:
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!