Docker

Docker 每个命令、每个选项,都有详尽的解释。

  • Why Docker?

    2013: Containers are a standardized unit of software that allows developers to isolate their app from its environment, solving the “it works on my machine” headache. Cloud Native Computing Foundation (CNCF)

Glossary
  • Docker Hub 上可以找到很多 container images。
  • Dockerfile
    通过 docker inspect 可以看到 dockerfile 的一些迹象。How can I see Dockerfile for each docker image?
    • CentOS Dockerfile 示例
      image.png
docker inspect:Return low-level information on Docker objects
  • docker inspect [OPTIONS] NAME|ID [NAME|ID...]
docker run:Run a command in a new container
  • $ docker run [OPTIONS] IMAGE[:TAG|@DIGEST] [COMMAND] [ARG...]
  • --name : 指定 container name。Container identification 的一种。
  • -v 参数 VOLUME (shared filesystems)
    --volume=[host-src:]container-dest[:]
  1. The host-src can either be an absolute path or a name value. If you supply an absolute path for the host-src, Docker bind-mounts to the path you specify. If you supply a name, Docker creates a named volume by that name.
  2. The container-dest must always be an absolute path such as /src/docs.
  • --mount 键值对,type 有3种值:bind, volume, tmpfs。
    • 使用 docker inspect 命令验证 bind mount 是否正确创建,查看 Mounts 部分。
bind-mount、volume、tmpfs-mount
Storage overview: Manage data in Docker
  • Use bind mounts
  • Use volumes
    Volumes are the preferred mechanism for persisting data generated by and used by Docker containers.
  • Use tmpfs mounts
    As opposed to volumes and bind mounts, a tmpfs mount is temporary, and only persisted in the host memory. When the container stops, the tmpfs mount is removed, and files written there won’t be persisted. 用于临时存储敏感文件等。

你可能感兴趣的:(Docker)