❤️❤❣️❤️❤❣️
❤️作者简介:2022新星计划第三季云原生与云计算赛道Top5、华为云享专家、云原生领域潜力新星
博客首页:C站个人主页
作者目的:如有错误请指正,将来会不断的完善笔记,帮助更多的Java爱好者入门,共同进步!
❤️❤❣️❤️❤❣️
本博文一共有6篇,如下
等你对Docker有一定理解的时候可以看高级篇,不过不太建议。
剧透:未来将出云原生技术-Kubernetes(k8s),此时的你可以对Docker进行统一管理、动态扩缩容等等。
看完之后你会对Docker有一定的理解,并能熟练的使用Docker进行容器化开发、以及Docker部署微服务、Docker网络等等。干起来!
Pivotal公司的Matt Stine于2013年首次提出**云原生(Cloud-Native)**的概念;2015年,云原生刚推广时,Matt Stine在《迁移到云原生架构》一书中定义了符合云原生架构的几个特征:12因素、微服务、自敏捷架构、基于API协作、扛脆弱性;到了2017年,Matt Stine在接受InfoQ采访时又改了口风,将云原生架构归纳为模块化、可观察、可部署、可测试、可替换、可处理6特质;而Pivotal最新官网对云原生概括为4个要点:DevOps+持续交付+微服务+容器。
总而言之,符合云原生架构的应用程序应该是:采用开源堆栈(K8S+Docker)进行容器化,基于微服务架构提高灵活性和可维护性,借助敏捷方法、DevOps支持持续迭代和运维自动化,利用云平台设施实现弹性伸缩、动态调度、优化资源利用率。
(此处摘选自《知乎-华为云官方帐号》)
总而言之:
Docker是一个高性能的容器引擎;
可以把本地源代码、配置文件、依赖、环境通通打包成一个容器即可以到处运行;
使用Docker安装软件十分方便,而且安装的软件十分精简,方便扩展。
1:http://mirrors.aliyun.com/centos/7.9.2009/isos/x86_64/ 进入下载页面
2:点击下面的File Name为CentOS-7-x86_64-DVD-2009.iso 链接即可。
3:通过VM虚拟机安装centos7。(这里省略了。)
[root@aubin ~]# yum list installed |grep docker
输出结果:
containerd.io.x86_64 1.4.4-3.1.el7 @docker-ce-stable
docker-ce-cli.x86_64 1:20.10.6-3.el7 @docker-ce-stable
docker-scan-plugin.x86_64 0.7.0-3.el7 @docker-ce-stable
yum -y remove containerd.io.x86_64
yum -y remove docker-ce-cli.x86_64
yum -y remove docker-scan-plugin.x86_64
sudo yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
sudo yum install docker-ce docker-ce-cli containerd.io
[root@aubin ~]# docker version
Client: Docker Engine - Community
Version: 20.10.14
API version: 1.41
Go version: go1.16.15
Git commit: a224086
Built: Thu Mar 24 01:49:57 2022
OS/Arch: linux/amd64
Context: default
Experimental: true
sudo systemctl start docker
配置镜像加速器方法。
针对Docker客户端版本大于 1.10.0 的用户,可以通过修改daemon配置文件/etc/docker/daemon.json来使用加速器
mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": ["https://u01jo9qv.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
最后就接入阿里云容器镜像加速器成功啦。
docker search hello-world
docker pull hello-world:latest
这些命令含义后面会讲,现在先不讲
docker pull hello-world:latest
Hello from Docker!
This message shows that your installation appears to be working correctly.
我们第一个docker程序完成啦!!!
sudo systemctl status docker
sudo systemctl enable docker
sudo docker version
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")
--tlskey string Path to TLS key file (default "/root/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit
Management Commands:
app* Docker App (Docker Inc., v0.9.1-beta3)
builder Manage builds
buildx* Docker Buildx (Docker Inc., v0.8.1-docker)
config Manage Docker configs
container Manage containers
context Manage contexts
image Manage images
manifest Manage Docker image manifests and manifest lists
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
scan* Docker Scan (Docker Inc., v0.17.0)
secret Manage Docker secrets
service Manage services
stack Manage Docker stacks
swarm Manage Swarm
system Manage Docker
trust Manage trust on Docker images
volume Manage volumes
Commands:
attach Attach local standard input, output, and error streams to a running container
build Build an image from a Dockerfile
commit Create a new image from a container's changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes to files or directories on a container's filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container's filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on Docker objects
kill Kill one or more running containers
load Load an image from a tar archive or STDIN
login Log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
pause Pause all processes within one or more containers
port List port mappings or a specific mapping for the container
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart one or more containers
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save one or more images to a tar archive (streamed to STDOUT by default)
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop one or more running containers
tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
top Display the running processes of a container
unpause Unpause all processes within one or more containers
update Update configuration of one or more containers
version Show the Docker version information
wait Block until one or more containers stop, then print their exit codes
docker images
docker images hello-world
docker search ubuntu
docker search --limit 1 ubuntu
docker search ubuntu --limit 1
docker pull ubuntu:latest
sudo docker system df
例如我们要删除hello-world镜像:
docker rmi -f hello-world
docker images -f dangling=true
docker rmi $(docker images -q -f dangling=true)
docker run -it --name "youzhengjie" ubuntu /bin/bash
docker ps
docker ps -a
docker ps -l
docker ps -a -n 1
docker ps -aq
❤️我们下一章见❤️