docker与虚拟机相比,没有虚拟化内核,转而使用宿主机的内核。因此docker更轻更快



docker缺点:后端兼容性测试需求。把软件安装在不同的操作系统上进行测试,观察软件运行是否良好。

不能用docker做兼容性测试

uname -a 查看系统内核版本

docker关键技术:

  • Namespace:通过名称控件达到了网络隔离
  • 联合文件系统:通过联合文件系统达到了文件目录的隔离
  • Cgroups:阻止容器中的软件和进程无限制的使用宿主机中的资源达到了资源隔离,如CPU和内存。

    组织容器除了内核共享,其他的都不是共享的

docker测试应用:

  • 搭建测试环境
  • 搭建各类基础服务
  • 搭建测试执行环境

选择docker的原因:

  • docker相对虚拟机轻量级,更轻更快
  • docker使用简单
  • docker共享,有大量的镜像可以使用

查看docker命令

Usage:	docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Options:
--config string Location of client config files (default "/Users/chenshanju/.docker")
-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 "/Users/chenshanju/.docker/ca.pem")
--tlscert string Path to TLS certificate file (default "/Users/chenshanju/.docker/cert.pem")
--tlskey string Path to TLS key file (default "/Users/chenshanju/.docker/key.pem")
--tlsverify Use TLS and verify the remote
-v, --version Print version information and quit Management Commands:
builder Manage builds
checkpoint Manage checkpoints
config Manage Docker configs
container Manage containers
engine Manage the docker engine
image Manage images
network Manage networks
node Manage Swarm nodes
plugin Manage plugins
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
deploy Deploy a new stack or update an existing stack
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 Run 'docker COMMAND --help' for more information on a command.

查看docker信息

docker版本号:从17年开始,以年-月命名版本号

Containers: 3    #当前的容器
Running: 1 #运行中的容器
Paused: 0
Stopped: 2 #已停止的容器
Images: 13 #镜像数量
Server Version: 18.09.0-ce-beta1 #docker版本
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
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: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 468a545b9edcd5932818eb9de8e72413e616e86e
runc version: 69663f0bd4b60df09991c08812a60108003fa340
init version: fec3683
Security Options:
seccomp
Profile: default
Kernel Version: 4.9.125-linuxkit
Operating System: Docker for Mac
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 3.855GiB
Name: linuxkit-025000000001
ID: IY7T:MW22:QBUX:KOJW:SOBV:TJUK:VXQA:HWGF:ZWXD:TAJP:KGPP:AKQ5
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
File Descriptors: 32
Goroutines: 57
System Time: 2018-11-02T08:12:50.1509806Z
EventsListeners: 2
HTTP Proxy: gateway.docker.internal:3128
HTTPS Proxy: gateway.docker.internal:3129
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
127.0.0.0/8
Registry Mirrors:
https://i2piuqyy.mirror.aliyuncs.com/
Live Restore Enabled: false
Product License: Community Engine

docker官方下载地址:https://hub.docker.com

注意:不用登陆,直接搜索镜像即可。一般选择官方镜像,如Jenkins,选择official

联合文件系统





如下载Jenkins时,有20层,Jenkins是一个经过20层文件修改生成的镜像



优点:节省硬盘空间

FAQ:

1.docker安装后,命令行使用docker,提示命令不可用,如下图所示


原因:/usr/local/bin未生效,将/usr/local/bin添加到环境变量即可

export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"

2.centOS安装docker,提示Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

解决方法:

systemctl daemon-reload
sudo service docker restart
sudo service docker status
#再次执行ps,不会再报错
docker ps

sudo service docker status

1021 docker初识的更多相关文章

  1. Docker初识

    <Docker--从入门到实践>是Docker技术的入门教程,学习时长两天,现整理关键点如下: 1. 什么是Docker? 轻量级操作系统虚拟化解决方案:Go语言实现:下图很好地说明了Do ...

  2. docker --- 初识

    Docker简介 Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的.可移植的.自给自足的容器.开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机).ba ...

  3. docker 初识之二(简单发布ASP.NET Core 网站)

    在发布ASP.NET Core网站以前,先介绍一下DaoCloud 一个免费的docker云容器服务平台.登陆官方网站,创建一台docker主机,这台主机有120分钟的使用时间,对于鄙人学习使用正好合 ...

  4. 1021 docker prometheus监控体系

    jmeter plugin监控的信息很少,只有cpu.内存.网络IO,但这些是不够的.例如对于分析mysql数据库的慢查询.最大连接数等更加细密度的信息. 服务端稳定测试的三个前提: 1.应用级别的自 ...

  5. 1021 docker搭建mysql、网络模式、grid

    1.搭建并连接mysql服务 1.1.mysql官方命令 https://hub.docker.com/_/mysql/ #下载mysql镜像: docker pull mysql #启动mysql: ...

  6. 1021 docker常用命令和Jenkins搭建

    docker常用命令 1.镜像管理 docker pull (镜像名) # 默认拉取最新版本的镜像 docker pull (镜像名:版本号) #拉取指定版本的镜像 docker push (镜像名) ...

  7. Docker初识笔记

    Docker docker说白了就是:环境打包 我们能用docker什么? 1.如果配置好本地的linux环境交接给其他人,很麻烦,交接时要告诉他,装这个装那个,还可能出现问题,那我直接把这个环境放到 ...

  8. Docker 初识之路

    一. 安装配置 1.安装依赖 sudo yum install -y yum-utils device-mapper-persistent-data lvm2   2.设置阿里云镜像源 sudo yu ...

  9. Docker学习のDocker初识

    一.Docker是什么 Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从Apache2.0协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然 ...

随机推荐

  1. 解决QML Window 增加radius效果

    做开发时,突然遇到 一个需要模态展示的对话框,做出来后,发现还要radius属性,增加时发现,Window控件不支持这个属性.如果是以前,原本就打算放弃了,但想一下,这种应该是支持的,既然接口上没有, ...

  2. 使用 if 表达式

    由于 if 本质上是一个原函数,它的返回值就是满足条件分支表达式的值,因此,if 表达式也可以用作内联函数.我们以 check_positive( )为例进行说明.尽管条件表达式中不另写 return ...

  3. Morgan logger

    var logger = require("morgan"); res.render = function(view, options, fn){ options = option ...

  4. Getting 'The AWS Access Key Id you provided does not exist in our records' error with Amazon MWS

    I upgraded from one version of Amazon MWS (marketplace web service) version https://mws.amazonservic ...

  5. Android中Tablayout设置下划线宽度 和 dp和px之间进行相互转换

    开发中遇到了一个问题,Tablayout设置下换线长度,看了点资料,分享给大家. 效果图:               直接贴代码(要在tabLayout添加完所有的tab后调用) public vo ...

  6. 初识webservice 服务

    1.获取电话号码归属地查询 首先访问: http://www.webxml.com.cn/zh_cn/web_services.aspx ①新建一个MyEclipse项目(WebService) ht ...

  7. 在am中定义消息集束,并在CO中验证之后抛出异常。

    需求:在页面上点某个按钮的时候,需要收集所有异常并抛出. -------------------------------------------方式1:参考 EBS OAF开发中的错误/异常处理(Er ...

  8. 伸展树的基本操作——以【NOI2004】郁闷的出纳员为例

    前两天老师讲了伸展树……虽然一个月以前自己就一直在看平衡树这一部分的书籍,也仔细地研读过伸展树地操作代码,但是就是没写过程序……(大概也是在平衡树的复杂操作和长代码面前望而生畏了)但是今天借着老师布置 ...

  9. 【Scipy】初步认识

    Scipy扩展包括多种多样的工具箱,这些工具致力于解决科学计算中的常见问题.不同的子模块对应不同的应用,比如插值, 整合, 优化, 图像处理, 统计, 特殊功能等等. scipy可以和其他的标准科学计 ...

  10. cdq分治的小结

    cdq分治 是一种特殊的分治 他的思想: 1.分治l,mid 2.分治mid+1,r 3.计算l,mid对mid+1,r的影响 3就是最关键的地方 这也是cdq的关键点 想到了这一步基本就可以做了 接 ...