美文网首页容器技术
八、容器和虚拟机

八、容器和虚拟机

作者: InsaneLoafer | 来源:发表于2021-12-04 19:50 被阅读0次

容器和虚拟机 Container vs VM

docker-vs-vm

容器不是Mini虚拟机

  • 容器其实是进程Containers are just processes

  • 容器中的进程被限制了对CPU内存等资源的访问

  • 当进程停止后,容器就退出了

容器的进程process

  • 显示容器的进程:docker container top <container ID>
    image.png

Note
以下是在Ubuntu20.04中演示,因Windows环境下的Docker和Linux具有一些差异。pstree 命令需要额外安装,可以使用 yum install psmisc 或者 sudo apt-get install psmisc 安装

➜  ~ docker container run -d nginx
57fe4033dd7e1e620a0b6a7b83b85d4f8f98772f0ce585624c384de254826fd0
➜  ~ docker container ls
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
57fe4033dd7e   nginx     "/docker-entrypoint.…"   4 seconds ago   Up 3 seconds   80/tcp    festive_proskuriakova
➜  ~ docker container top 57f
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                7646                7625                0                   12:14               ?                   00:00:00            nginx: master process nginx -g daemon off;
systemd+            7718                7646                0                   12:14               ?                   00:00:00            nginx: worker process
➜  ~
➜  ~
➜  ~  ps -aef --forest
UID        PID  PPID  C STIME TTY          TIME CMD
root         1     0  0 May14 ?        00:00:00 /init
root       157     1  0 May14 ?        00:00:00 /init
root       523   157  0 May14 ?        00:02:32  \_ /usr/bin/dockerd -p /var/run/docker.pid
root       545   523  0 May14 ?        00:25:55  |   \_ containerd --config /var/run/docker/containerd/containerd.toml --log-level info
root      7625   157  0 12:14 ?        00:00:00  \_ /usr/bin/containerd-shim-runc-v2 -namespace moby -id 57fe4033dd7e1e620a0b6a7b83b85d4f8f98772f0ce585624c384de254826fd0 -address /var/run/d
root      7646  7625  0 12:14 ?        00:00:00      \_ nginx: master process nginx -g daemon off;
systemd+  7718  7646  0 12:14 ?        00:00:00          \_ nginx: worker process
root      6442     1  0 May18 ?        00:00:00 /init
root      6443  6442  0 May18 ?        00:00:00  \_ /init
penxiao   6444  6443  0 May18 pts/2    00:00:01      \_ -zsh
penxiao   7770  6444  0 12:15 pts/2    00:00:00          \_ ps -aef --forest
➜  ~
➜  ~ pstree -halps 7718
init,1
└─init,157
    └─containerd-shim,7625 -namespace moby -id 57fe4033dd7e1e620a0b6a7b83b85d4f8f98772f0ce585624c384de254826fd0 -address /var/run/docker/containerd/containerd.sock
        └─nginx,7646
            └─nginx,7718

Gain Access to the MobyLinux VM on Windows or MacOS

https://nickjanetakis.com/blog/docker-tip-70-gain-access-to-the-mobylinux-vm-on-windows-or-macos

相关文章

  • 八、容器和虚拟机

    容器和虚拟机 Container vs VM[https://dockertips.readthedocs.io/...

  • 容器技术和虚拟机的差异和联系

    容器技术和虚拟机的差异和联系,在了解之前,我们需要了解虚拟机是什么,虚拟机有什么用,以及容器是什么,容器有什么用[...

  • 第1章 容器技术和Docker简介

    容器技术。docker。 到底什么是docker? 虚拟机和容器的区别。创建虚拟机,不同应用在不同虚拟机内进行隔离...

  • vagrant虚拟机运行docker容器

    vagrant虚拟机运行docker容器 虚拟机ifconfig查看dockerip和虚拟机ip 宿主机 rou...

  • Docker基本原理与概念

    一. 容器与虚拟机的区别 和虚拟机相比,容器更加轻量级。因为运行在相同宿主机上的容器共享一个操作系统,可以节省大量...

  • 关于容器和虚拟机

    什么是“容器”和“虚拟机”? 容器和虚拟机目标一致:通过一个独立的单元将应用与其依赖隔离,这个独立单元可以在任何地...

  • 8.容器化(不全

    无论是容器,还是虚拟机,都依赖于内核中的技术,虚拟机依赖的是 KVM,容器依赖的是 namespace 和 cgr...

  • Linux环境基于CentOS7 搭建部署Docker容器

    1.Docker容器概述 区分Docker容器技术和VM虚拟机技术:evernotecid://394EFE90-...

  • Docker 的概念和理解

    Docker 容器和虚拟机的区别 虚拟机需要安装Guest OS。如果运行多个虚拟机,需要安装多个Guest OS...

  • Docker总结

    我们在理解docker之前,首先我们得先区分清楚两个概念,容器和虚拟机。 可能很多读者朋友都用过虚拟机,而对容器这...

网友评论

    本文标题:八、容器和虚拟机

    本文链接:https://www.haomeiwen.com/subject/oyabtrtx.html