没有合适的资源?快使用搜索试试~ 我知道了~
docker入门知识总结,包括概述,安装,与基本的使用技巧入门
需积分: 5 0 下载量 60 浏览量
2024-09-13
22:27:36
上传
评论
收藏 227KB PDF 举报
温馨提示
docker安装--docker入门知识总结,包括概述,安装,与基本的使用技巧入门
资源推荐
资源详情
资源评论
docker⼊门知识总结⼊门知识总结
DOCKER
1.概述概述
1.1 为什么要使⽤为什么要 使⽤ docker
每次发布项⽬都要重新部署服务器,是否已经让你厌恶?项⽬发布能不能连同运⾏环境⼀起⾃动化部署?为了解决这个问题,docker出现了。
docker的灵感来⾃于集装箱,重点在于隔离机制,通过隔离机制能做到避免多个应⽤的端⼝冲突,实现单台服务器部署多个运⾏环境。
1.2 docker历史历史
诞⽣于2010年,⼏个搞IT的热⾎青年⾛到⼀起创办了dotCloud公司;
起初由于代码不开源,⾏业内并没有太多⼈使⽤docker;
2013年,docker决定开放源代码,随后使⽤docker的⼈越来越多;
docker是⼀种虚拟技术,但⼜不同于VMware,它是⼀种容器技术,⽐虚拟机要轻量得多。
1.3 ⽂档地址和仓库地址⽂档地址 和仓库地址
2.安装安装
2.1 Docker基本组成基本组成
2.2 基本概念基本概念
镜像(Image)docker镜像好⽐是⼀个模板,可以通过这个模板来创建容器服务,通过这个镜像可以创建多个容器(最终服务运⾏或者项⽬运⾏就是在容器中的)。
容器(container)docker利⽤容器技术,独⽴运⾏⼀个或者⼀组应⽤,通过镜像来创建。
仓库(repository)存放镜像的地⽅,分为公有仓库和私有仓库。
2.3 安装步骤安装步骤
环境:centOS 7
# 以下内容为操作系统具体信息
uname -r
3.10.0-1160.el7.x86_64
cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
# 1.卸载旧版本docker
[root@localhost ~]# yum remove docker \
> docker-client \
> docker-client-latest \
> docker-common \
> docker-latest \
> docker-latest-logrotate \
> docker-logrotate \
> docker-engine
Loaded plugins: fastestmirror
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
# 2.安装yum相关的安装包
[root@localhost lib]# yum install yum-utils
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Package yum-utils-1.1.31-54.el7_8.noarch already installed and latest version
Nothing to do
# 3.设置镜像仓库(此处最好⽤国内镜像,国外镜像速度不稳定)
[root@localhost lib]# yum-config-manager \
> --add-repo \
> http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
# 4.安装docker相关安装包
[root@localhost lib]# yum install docker-ce docker-ce-cli containerd.io
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/primary_db | 55 kB 00:00:03
(2/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:03
Resolving Dependencies
--> Running transaction check
---> Package containerd.io.x86_64 0:1.4.3-3.1.el7 will be installed
--> Processing Dependency: container-selinux >= 2:2.74 for package: containerd.io-1.4.3-3.1.el7.x86_64
--> Processing Dependency: libseccomp for package: containerd.io-1.4.3-3.1.el7.x86_64
---> Package docker-ce.x86_64 3:20.10.3-3.el7 will be installed
--> Processing Dependency: docker-ce-rootless-extras for package: 3:docker-ce-20.10.3-3.el7.x86_64
---> Package docker-ce-cli.x86_64 1:20.10.3-3.el7 will be installed
--> Running transaction check
---> Package container-selinux.noarch 2:2.119.2-1.911c772.el7_8 will be installed
---> Package docker-ce-rootless-extras.x86_64 0:20.10.3-3.el7 will be installed
--> Processing Dependency: fuse-overlayfs >= 0.7 for package: docker-ce-rootless-extras-20.10.3-3.el7.x86_64
--> Processing Dependency: slirp4netns >= 0.4 for package: docker-ce-rootless-extras-20.10.3-3.el7.x86_64
---> Package libseccomp.x86_64 0:2.3.1-4.el7 will be installed
--> Running transaction check
---> Package fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 will be installed
--> Processing Dependency: libfuse3.so.3(FUSE_3.2)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3(FUSE_3.0)(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
--> Processing Dependency: libfuse3.so.3()(64bit) for package: fuse-overlayfs-0.7.2-6.el7_8.x86_64
---> Package slirp4netns.x86_64 0:0.4.3-4.el7_8 will be installed
--> Running transaction check
---> Package fuse3-libs.x86_64 0:3.6.1-4.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================================================================================================================
Package Arch Version Repository Size
================================================================================================================================================================================
Installing:
containerd.io x86_64 1.4.3-3.1.el7 docker-ce-stable 33 M
docker-ce x86_64 3:20.10.3-3.el7 docker-ce-stable 27 M
docker-ce-cli x86_64 1:20.10.3-3.el7 docker-ce-stable 33 M
Installing for dependencies:
container-selinux noarch 2:2.119.2-1.911c772.el7_8 extras 40 k
docker-ce-rootless-extras x86_64 20.10.3-3.el7 docker-ce-stable 9.0 M
fuse-overlayfs x86_64 0.7.2-6.el7_8 extras 54 k
fuse3-libs x86_64 3.6.1-4.el7 extras 82 k
libseccomp x86_64 2.3.1-4.el7 base 56 k
slirp4netns x86_64 0.4.3-4.el7_8 extras 81 k
Transaction Summary
================================================================================================================================================================================
Install 3 Packages (+6 Dependent packages)
Total download size: 102 M
Installed size: 423 M
Is this ok [y/d/N]: y
Downloading packages:
(1/9): container-selinux-2.119.2-1.911c772.el7_8.noarch.rpm | 40 kB 00:00:00
warning: /var/cache/yum/x86_64/7/docker-ce-stable/packages/docker-ce-20.10.3-3.el7.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 621e9f35: NOKEYB/s | 30 MB 00:00:20 ETA
Public key for docker-ce-20.10.3-3.el7.x86_64.rpm is not installed
(2/9): docker-ce-20.10.3-3.el7.x86_64.rpm | 27 MB 00:00:08
(3/9): docker-ce-cli-20.10.3-3.el7.x86_64.rpm | 33 MB 00:00:09
(4/9): fuse-overlayfs-0.7.2-6.el7_8.x86_64.rpm | 54 kB 00:00:00
(5/9): slirp4netns-0.4.3-4.el7_8.x86_64.rpm | 81 kB 00:00:00
(6/9): fuse3-libs-3.6.1-4.el7.x86_64.rpm | 82 kB 00:00:00
(7/9): libseccomp-2.3.1-4.el7.x86_64.rpm | 56 kB 00:00:00
(8/9): docker-ce-rootless-extras-20.10.3-3.el7.x86_64.rpm | 9.0 MB 00:00:02
(9/9): containerd.io-1.4.3-3.1.el7.x86_64.rpm | 33 MB 00:00:25
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.0 MB/s | 102 MB 00:00:25
Retrieving key from https://download.docker.com/linux/centos/gpg
Importing GPG key 0x621E9F35:
Userid : "Docker Release (CE rpm) <docker@docker.com>"
Fingerprint: 060a 61c5 1b55 8a7f 742b 77aa c52f eb6b 621e 9f35
From : https://download.docker.com/linux/centos/gpg
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libseccomp-2.3.1-4.el7.x86_64 1/9
Installing : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 2/9
Installing : containerd.io-1.4.3-3.1.el7.x86_64 3/9
Installing : slirp4netns-0.4.3-4.el7_8.x86_64 4/9
Installing : 1:docker-ce-cli-20.10.3-3.el7.x86_64 5/9
Installing : fuse3-libs-3.6.1-4.el7.x86_64 6/9
Installing : fuse-overlayfs-0.7.2-6.el7_8.x86_64 7/9
Installing : 3:docker-ce-20.10.3-3.el7.x86_64 8/9
Installing : docker-ce-rootless-extras-20.10.3-3.el7.x86_64 9/9
Verifying : fuse3-libs-3.6.1-4.el7.x86_64 1/9
Verifying : 3:docker-ce-20.10.3-3.el7.x86_64 2/9
Verifying : fuse-overlayfs-0.7.2-6.el7_8.x86_64 3/9
Verifying : slirp4netns-0.4.3-4.el7_8.x86_64 4/9
Verifying : 2:container-selinux-2.119.2-1.911c772.el7_8.noarch 5/9
Verifying : libseccomp-2.3.1-4.el7.x86_64 6/9
Verifying : containerd.io-1.4.3-3.1.el7.x86_64 7/9
Verifying : docker-ce-rootless-extras-20.10.3-3.el7.x86_64 8/9
Verifying : 1:docker-ce-cli-20.10.3-3.el7.x86_64 9/9
Installed:
containerd.io.x86_64 0:1.4.3-3.1.el7 docker-ce.x86_64 3:20.10.3-3.el7 docker-ce-cli.x86_64 1:20.10.3-3.el7
Dependency Installed:
container-selinux.noarch 2:2.119.2-1.911c772.el7_8 docker-ce-rootless-extras.x86_64 0:20.10.3-3.el7 fuse-overlayfs.x86_64 0:0.7.2-6.el7_8 fuse3-libs.x86_64 0:3.6.1-4.el7
libseccomp.x86_64 0:2.3.1-4.el7 slirp4netns.x86_64 0:0.4.3-4.el7_8
Complete!
# 5.查看docker 版本
[root@localhost lib]# docker version
Client: Docker Engine - Community
Version: 20.10.3
API version: 1.41
Go version: go1.13.15
Git commit: 48d30b5
Built: Fri Jan 29 14:34:14 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
# 6.启动docker
[root@localhost lib]# systemctl start docker
# 7.运⾏hello-world镜像
[root@localhost lib]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete
Digest: sha256:95ddb6c31407e84e91a986b004aee40975cb0bda14b5949f6faac5d2deadb4b9
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.
(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/
# 8.查看hello-world镜像
[root@localhost docker]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest bf756fb1ae65 13 months ago 13.3kB
如需卸载可执⾏以下命令
yum remove docker-ce docker-ce-cli containerd.io
rm -rf /var/lib/docker
2.4 docker为什么⽐虚拟机快为什么⽐ 虚拟机快
1. docker有着⽐虚拟机更少的抽象层
2. docker利⽤宿主机的内核,⽽VMware相当于重装⼀台电脑
3.命令命令
3.1 帮助命令帮助命令
[root@localhost ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)
Server:
Containers: 2
Running: 0
Paused: 0
Stopped: 2
Images: 1
Server Version: 20.10.3
Storage Driver: overlay2
Backing Filesystem: xfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc version: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
init version: de40ad0
Security Options:
seccomp
Profile: default
Kernel Version: 3.10.0-1160.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 991.3MiB
Name: localhost.localdomain
ID: J6FX:JPAO:CN55:Z27Y:35FS:7LIE:NNJX:FDPN:REID:74WW:GT66:OZJM
Docker Root Dir: /var/lib/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
[root@localhost ~]# docker version
Client: Docker Engine - Community
Version: 20.10.3
API version: 1.41
Go version: go1.13.15
Git commit: 48d30b5
Built: Fri Jan 29 14:34:14 2021
OS/Arch: linux/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.3
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 46229ca
Built: Fri Jan 29 14:32:37 2021
OS/Arch: linux/amd64
Experimental: false
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
[root@localhost ~]# docker --help
Usage: docker [OPTIONS] COMMAND
A self-sufficient runtime for containers
Options:
--config string Location of client config files (default "/root/.docker")
-c, --context string Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker context use")
-D, --debug Enable debug mode
-H, --host list Daemon socket(s) to connect to
-l, --log-level string Set the logging level ("debug"|"info"|"warn"|"error"|"fatal") (default "info")
--tls Use TLS; implied by --tlsverify
--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")
剩余11页未读,继续阅读
资源评论
学长阿拉丁
- 粉丝: 3178
- 资源: 1181
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- C语言-leetcode题解之83-remove-duplicates-from-sorted-list.c
- C语言-leetcode题解之79-word-search.c
- C语言-leetcode题解之78-subsets.c
- C语言-leetcode题解之75-sort-colors.c
- C语言-leetcode题解之74-search-a-2d-matrix.c
- C语言-leetcode题解之73-set-matrix-zeroes.c
- 树莓派物联网智能家居基础教程
- YOLOv5深度学习目标检测基础教程
- (源码)基于Arduino和Nextion的HMI人机界面系统.zip
- (源码)基于 JavaFX 和 MySQL 的影院管理系统.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功