下半年学习规划

下半年学习规划

以往学习的比较杂乱,现在统一制定下下半年的学习规划,年底截止,完成的打钩

阅读

  • 财经类两本
  • 悬疑、科幻、历史类
    • 《明朝1566》
    • 《白夜行》
    • 《放学后》
  • 英语阅读

工程能力

  • 掌握GO编程、阅读3本相关书籍、并重构IOT通信系统
  • 掌握Docker应用、阅读1本相关书籍,时间富足可以学习Kubernetes
  • 掌握Redis、MySQL集群的使用,并深入了解
  • 掌握Python的高级使用,并参加Kaggle比赛

算法能力

  • 学习基本的机器学习知识并应用起来
    • 线性回归
    • 逻辑回归
    • 神经网络
    • 算法评估
    • 支持向量机
    • 聚类
    • 异常检测
    • 实战
  • 学习深度学习相关知识
  • 复习数据结构和算法,参考书籍算法导论

Docker使用

  Docker使用Google公司推出的Go语言进行开发实现,基于Linux 内核的cgroup,namespace,以及 AUFS 类的Union FS等技术对进程进行封装隔离,属于操作系统层面的虚拟化技术。由于隔离的进程独立于宿主和其它的隔离的进程,因此也称其为容器。Docker 在容器的基础上,进行了进一步的封装,从文件系统、网络互联到进程隔离等,极大的简化了容器的创建和维护。而虚拟机会虚拟出一套硬件,在其上运行一套操作系统, 因此Docker 技术比虚拟机技术更为轻便、快捷。

快速上手

安装

curl -sSL https://get.docker.com/ |sh
注意使用国内镜像源

运行

docker run --name demo -it -d centos

基本概念

镜像

镜像是一个特殊的文件系统,除了提供容器运行时所需的程序、库、资源、配置等文件外,还包含了一些为运行时准备的一些配置参数(如匿名卷、环境变量、用户等)。镜像不包含任何动态数据,其内容在构建之后也不会被改变。在构建的过程中是一层一层构建的,前一层是后一层的基础,每一层构建完就不会发生改变。
相关命令:


Usage:docker image COMMAND Manage images Commands: build Build an image from a Dockerfile history Show the history of an image import Import the contents from a tarball to create a filesystem image inspect Display detailed information on one or more images load Load an image from a tar archive or STDIN ls List images prune Remove unused images pull Pull an image or a repository from a registry push Push an image or a repository to a registry rm Remove one or more images save Save one or more images to a tar archive (streamed to STDOUT by default) tag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

容器

  容器可以理解为镜像运行时的实体,可以被创建、启动、停止、删除、暂停等
相关命令:

Usage:docker container COMMAND
Manage containers
Commands:
  attach      Attach local standard input, output, and error streams to a running container
  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
  exec        Run a command in a running container
  export      Export a container's filesystem as a tar archive
  inspect     Display detailed information on one or more containers
  kill        Kill one or more running containers
  logs        Fetch the logs of a container
  ls          List containers
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  prune       Remove all stopped containers
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  run         Run a command in a new container
  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
  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
  wait        Block until one or more containers stop, then print their exit codes

注意事项:

  • 在执行命令的时候推荐用exec而不是attach,避免exit的时候容器退出
  • 可以使用inspect 命令查看容器详细信息,使用logs命令查看相关日志,用于定位错误
  • 容器与容器之间默认是无法互联的,可以使用docker-compose部署或使用link参数在运行时组网,不过建议使用docker create network命令构建网络

仓库

镜像存储分发的地方,类似于GITHUB,推荐使用阿里云做加速

其它内容

数据管理

数据卷

数据卷 是一个可供一个或多个容器使用的特殊目录,它绕过 UFS,可以提供很多有用的特性:

  • 数据卷可以在容器之间共享和重用

  • 对数据卷的修改会立马生效

  • 对数据卷的更新,不会影响镜像

  • 数据卷默认会一直存在,即使容器被删除

 docker volume create my-vol
 docker volume ls
 docker volume rm my-vol

网络连接

  • -p 映射 TCP/UDP 不一样
  • 创建网络
  • 容器互联

DockerFile的编写

  • 参考网上教程

Compose的使用

  • 使用PIP安装,安装后创建compose文件即可使用,管理起来比较方便而且默认是互联的

Kubernetes的使用

一些示例

Docker run --name test -it -d centos bash 启动交互式命令行
Docker run --name redis -it -d redis redis-server --appendonly yes -v /home/work/data/redis:/data 使用AUFS在宿主机保存Redis数据
Docker run --name test -it -d -p 23:22  centos bash 端口23 映射到22