一.Docker概述

1.Docker简介

       Docker是一个开源的应用容器引擎;是一个轻量级容器技术;Docker支持将软件编译成一个镜像;然后在镜像中各种软件做好配置,将镜像发布出去,其他使用者可以直接使  用这个镜像;运行中的这个镜像称为容器,容器启动是非常快速的。

对比传统虚拟机总结

 Docker 简介与shell操作使用

2.Docker术语

  • docker主机(Host):安装了Docker程序的机器(Docker直接安装在操作系统之上);
  • docker客户端(Client):连接docker主机进行操作; docker仓库(Registry):用来保存各种打包好的软件镜像;
  • docker镜像(Images):软件打包好的镜像;放在docker仓库中;
  • docker容器(Container):镜像启动后的实例称为一个容器;容器是独立运行的一个或一组应用。

Docker 简介与shell操作使用

使用Docker的步骤:

1)、安装Docker

2)、去Docker仓库找到这个软件对应的镜像;

3)、使用Docker运行这个镜像,这个镜像就会生成一个Docker容器;

4)、对容器的启动停止就是对软件的启动停止;

二.Docker安装

1.安装linux虚拟机

1)、VMWare、VirtualBox(安装); VirtualBox下载地址: https://www.virtualbox.org/wiki/Downloads

2)、安装linux系统CentOS7;

3)、双击启动linux虚拟机;使用 root/ 123456登陆

4)、使用客户端连接linux服务器进行命令操作;

5)、设置虚拟机网络;桥接网络=选好网卡==接入网线;

6)、设置好网络以后使用命令重启虚拟机的网络     service network restart         ip addr

2.linux上安装docker

1、检查内核版本,必须是3.10及以上 uname ‐r ,如果不是需要 yum update升级软件包及内核

Docker 简介与shell操作使用

2、安装docker  ,输入y确认安装

[root@localhost ~]# yum install docker

Docker 简介与shell操作使用

yum方式安装的docker不是最新版的,通过下面方式安装最新版的docker

[root@localhost ~]# curl -sSL https://get.daocloud.io/docker | sh

Docker 简介与shell操作使用

3、启动docker 查看docker版本号

[root@localhost ~]# systemctl start docker

4、设置开机启动docker

[root@localhost ~]# systemctl enable docker

Docker 简介与shell操作使用

5、停止docker

[root@localhost ~]# systemctl stop docker

6、查看docker帮助

[root@localhost ~]# docker --help

帮助命令如下:

[root@localhost ~]# docker --help

Usage:  docker COMMAND

A self-sufficient runtime for containers

Options:
      --config string      Location of client config files (default "/root/.docker")
  -D, --debug              Enable debug mode
      --help               Print usage
  -H, --host list          Daemon socket(s) to connect to (default [])
  -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:
  container   Manage containers
  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
  volume      Manage volumes

Commands:
  attach      Attach 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 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 --help

相关文章: