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. MyBatis获取SqlSession

    package com.ykmimi.dao; import org.apache.ibatis.session.SqlSession; import com.ykmimi.entity.Studen ...

  2. YAML(摘录)

    YAML:维基百科 一个用来表达数据序列的格式.强调以数据为中心的标记语言. 使用空白符缩进和大量依赖外观的特殊,适合编辑数据结构,配置文件. 基本格式: 缩进/区块 和内置两者格式,来表示array ...

  3. @RequestParam注解的作用及用法

    最简单的两种写法,在写接口时:加或不加@RequestParam注解的区别 第一种写法参数为非必传,第二种写法参数为必传.参数名为userId 第二种写法可以通过@RequestParam(requi ...

  4. wikioi 1021 玛丽卡

    链接:http://wikioi.com/problem/1021/ 这题挺有意思的,虽然比较水,但是让我想起来那次百度or腾讯的一道最大流的题目,很给力,也是对最后找边进行优化,不过这题比那题简单多 ...

  5. 前端工程构建工具——Yeoman

    一.Yeoman 简介 通常在开发新项目时我们都需要配置工程环境,开发目录,需要下载一些库.框架文件(如 jQuery.Backbone 等),配置编译环境(Less.Sass.Coffeescrip ...

  6. 蓝桥杯练习系统历届试题 带分数 dfs

    问题描述 100 可以表示为带分数的形式:100 = 3 + 69258 / 714. 还可以表示为:100 = 82 + 3546 / 197. 注意特征:带分数中,数字1~9分别出现且只出现一次( ...

  7. 多线程--Thread.join方法

    在Thread类的Api中,Join的作用是让当前线程等待目标线程结束之后才继续执行. thread.Join把指定的线程加入到当前线程,可以将两个交替执行的线程合并为顺序执行的线程.  比如在线程B ...

  8. Android Studio 1.5 注解配置

    Project的build.gradle文件配置如下: // Top-level build file where you can add configuration options common t ...

  9. 基于Jquery实现省份、城市、区县三级联动

    前端感觉写的比较少,也是为了练手,下午没事用来写了这个三级联动,也是第一次写这东西. 据我了解,城市信息可以选择存在数据库或者直接写在前端,为了省事,我直接写在前端,下面是我的代码: <!DOC ...

  10. Python3 循环语句(十)

    Python中的循环语句有 for 和 while. Python循环语句的控制结构图如下所示: while 循环 Python中while语句的一般形式: while 判断条件: 语句 同样需要注意 ...