Docker命令练习(1)

Docker命令练习

使用好处:数据隔离(沙盒环境),可以降低成本。

架构的标准:SAAS+Docker+K8S

打开docker

image-20220809102539876

镜像:image | 容器:container

镜像是从什么地方获取?是从docker hub来获取,获取的命令是:pull

查看镜像列表: docker images

 

 

运行hello-world容器的最新版本运行后删除记录

image-20220809102335359

下载LInux镜像执行linux操作命令

image-20220809103255564

 

image-20220809103501993

docker的每个版本都是沙盒环境(数据隔离),退出以后会清空所有操作。

-it: 开启交互式命令

--rm:容器退出的时候删除容器的记录

docker run -it --rm imageName:version(版本后不跟具体版本会默认获取最新版本)

docker pull imageName:version latest(默认获取最新的版本)

在windows系统中过滤出特定的镜像:docker images| findstr hello-world

在Linux系统中过滤出特定的镜像:docker images | grep hello-world

通过镜像ID查看镜像的详细信息:docker image inspect IMAGE ID(afb6fca791e0)

image-20220809110515038

查看有镜像ID:docker images -q

image-20220809110815188

windos:cls 清除

镜像运行后在容器中生成一条记录,那么这个删除镜像的逻辑是:

A:查看容器运行记录 :docker ps -a

B:停止容器的运行: docker stop c9cefc81c76bC

C:删除容器及运行记录 :docker rm c9cefc81c76bC

D:删除镜像:docker rmi hello-world

image-20220809112712058

运行镜像

-it:开启交互式的命令 --rm:容器退出时删除容器的记录信息 --name:指定容器的名称 -d:后台方式运行容器

nginx的默认端口是80,Nginx (engine x) 是一个高性能的HTTP和反向代理web服务器,同时也提供了IMAP/POP3/SMTP服务。

-p80:80 -p是指定端口 本地端口:容器端口(尽量保持一致) | -P是指定任意端口

docker pull nginx 获取nginx镜像,

docker run -d -p80:80 nginx

docker run -d -P nginx

image-20220809150755459

image-20220809152558097

运行centos:7.9.2009和镜像

image-20220809165754859

镜像的复制:docker tag afb6fca791e0 centos:7.8.2004

image-20220809155134745

通过tag删除镜像

image-20220809155538266

 
posted @ 2022-08-09 17:25  LaraCroft  阅读(68)  评论(0编辑  收藏  举报