1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢(xún)
      選擇下列產(chǎn)品馬上在線(xiàn)溝通
      服務(wù)時(shí)間:8:30-17:00
      你可能遇到了下面的問(wèn)題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
      docker中info命令請(qǐng)求流程分析-創(chuàng)新互聯(lián)

      這篇文章主要介紹docker中info命令請(qǐng)求流程分析,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

      創(chuàng)新互聯(lián)主要從事網(wǎng)站設(shè)計(jì)制作、成都做網(wǎng)站、網(wǎng)頁(yè)設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)渠縣,十載網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專(zhuān)業(yè),歡迎來(lái)電咨詢(xún)建站服務(wù):028-86922220

      先上一個(gè)流程圖示

      docker中info命令請(qǐng)求流程分析

      僅供自己梳理了解最新代碼流程,有些細(xì)節(jié)并不會(huì)展開(kāi)深挖
      1、進(jìn)入客戶(hù)端接收代碼塊,由runInfo方法返回內(nèi)容
      github.com/docker/cli/cli/command/system/info.go

      // NewInfoCommand creates a new cobra.Command for `docker info`
      func NewInfoCommand(dockerCli command.Cli) *cobra.Command {
          var opts infoOptions
      
          cmd := &cobra.Command{
              Use:   "info [OPTIONS]",
              Short: "Display system-wide information",
              Args:  cli.NoArgs,
              RunE: func(cmd *cobra.Command, args []string) error {
                  return runInfo(dockerCli, &opts)
              },
          }
      
      func runInfo(dockerCli command.Cli, opts *infoOptions) error {
          ctx := context.Background()
          info, err := dockerCli.Client().Info(ctx)

      2、   請(qǐng)求轉(zhuǎn)發(fā)給docker daemon處理
      github.com/docker/cli/vendor/github.com/docker/docker/client/info.go

      // Info returns information about the docker server.
      func (cli *Client) Info(ctx context.Context) (types.Info, error) {
          var info types.Info
          serverResp, err := cli.get(ctx, "/info", url.Values{}, nil)

      3、docker daemon的監(jiān)聽(tīng)路由,進(jìn)入到SystemInfo處理  
      github.com/docker/docker/api/server/router/system/system.go

      // NewRouter initializes a new system router
      func NewRouter(b Backend, c ClusterBackend, fscache *fscache.FSCache, builder *buildkit.Builder, features *map[string]bool) router.Router {
         router.NewGetRoute("/info", r.getInfo),

      github.com/docker/docker/api/server/router/system/system_routes.go

      func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
          info, err := s.backend.SystemInfo()

      4、經(jīng)過(guò)進(jìn)入systemInfo處理方法,可知container狀態(tài)信息是已經(jīng)在內(nèi)存中數(shù)據(jù)  
      github.com/docker/docker/daemon/info.go

      // SystemInfo returns information about the host server the daemon is running on.
      func (daemon *Daemon) SystemInfo() (*types.Info, error) {
          sysInfo := sysinfo.New(true)
          cRunning, cPaused, cStopped := stateCtr.get()
      
          v := &types.Info{
              ID:                 daemon.ID,
              Containers:         cRunning + cPaused + cStopped,
              ContainersRunning:  cRunning,
              ContainersPaused:   cPaused,
              ContainersStopped:  cStopped,

      5、找到設(shè)置container運(yùn)行狀態(tài)的數(shù)據(jù)方法    
      github.com/docker/docker/daemon/metrics.go

      func (ctr *stateCounter) set(id, label string) {
          ctr.mu.Lock()
          ctr.states[id] = label
          ctr.mu.Unlock()
      }

      6、容器狀態(tài)數(shù)據(jù)來(lái)源
      6.1、順著設(shè)置方法找到在創(chuàng)建container時(shí)會(huì)設(shè)置一條數(shù)據(jù),這是初始化的數(shù)據(jù)
      github.com/docker/docker/daemon/create.go

      // Create creates a new container from the given configuration with a given name.
      func (daemon *Daemon) create(params types.ContainerCreateConfig, managed bool) (retC *container.Container, retErr error) {
         stateCtr.set(container.ID, "stopped")

      6.2、容器操作(暫停、啟動(dòng)、恢復(fù))
      github.com/docker/docker/daemon/pause.go

      // containerPause pauses the container execution without stopping the process.
      // The execution can be resumed by calling containerUnpause.
      func (daemon *Daemon) containerPause(container *container.Container) error {
          container.Paused = true
          daemon.setStateCounter(container)

      github.com/docker/docker/daemon/start.go

      // containerStart prepares the container to run by setting up everything the
      // container needs, such as storage and networking, as well as links
      // between containers. The container is left waiting for a signal to
      // begin running.
      func (daemon *Daemon) containerStart(container *container.Container, checkpoint string, checkpointDir string, resetRestartManager bool) (err error) {
          container.SetRunning(pid, true)
          container.HasBeenManuallyStopped = false
          container.HasBeenStartedBefore = true
          daemon.setStateCounter(container)

      github.com/docker/docker/daemon/unpause.go

      // containerUnpause resumes the container execution after the container is paused.
      func (daemon *Daemon) containerUnpause(container *container.Container) error {
          container.Paused = false
          daemon.setStateCounter(container)

      6.3、docker重啟后,從目錄中獲取容器狀態(tài)
      github.com/docker/docker/daemon/daemon.go

      func (daemon *Daemon) restore() error {
         for _, c := range containers {
           //從文件config.v2.json中獲取容器狀態(tài)
           daemon.setStateCounter(c)
      
           //如文件中的狀態(tài)是運(yùn)行或暫停,再進(jìn)行檢查,并重置狀態(tài)
           if c.IsRunning() || c.IsPaused() {
           default:
                                  // running
                                  c.Lock()
                                  c.Paused = false
                                  daemon.setStateCounter(c)

      7、事件變更重置容器狀態(tài)(windows)
      7.1、container狀態(tài)變更的信息方法  
      github.com/docker/docker/daemon/monitor.go

      func (daemon *Daemon) setStateCounter(c *container.Container) {
          switch c.StateString() {
          case "paused":
              stateCtr.set(c.ID, "paused")
          case "running":
              stateCtr.set(c.ID, "running")
          default:
              stateCtr.set(c.ID, "stopped")
          }
      }

      7.2、windows事件監(jiān)聽(tīng)
      github.com/docker/docker/daemon/monitor.go

      // ProcessEvent is called by libcontainerd whenever an event occurs
      func (daemon *Daemon) ProcessEvent(id string, e libcontainerd.EventType, ei libcontainerd.EventInfo) error {
          case libcontainerd.EventExit:
             daemon.setStateCounter(c)
          case libcontainerd.EventStart:
      
              // This is here to handle start not generated by docker
              if !c.Running {
                  c.SetRunning(int(ei.Pid), false)
                  c.HasBeenManuallyStopped = false
                  c.HasBeenStartedBefore = true
                  daemon.setStateCounter(c)
      
          case libcontainerd.EventPaused:
      
              if !c.Paused {
                  c.Paused = true
                  daemon.setStateCounter(c)
      
          case libcontainerd.EventResumed:
              if c.Paused {
                  c.Paused = false
                  daemon.setStateCounter(c)

      8、開(kāi)啟啟動(dòng)docker時(shí)的debug模式,獲取文件描述、goroute等信息
      dockerd --debug
      github.com/docker/cli/cli/command/system/info.go

      if info.Debug {
              fmt.Fprintln(dockerCli.Out(), " File Descriptors:", info.NFd)
              fmt.Fprintln(dockerCli.Out(), " Goroutines:", info.NGoroutines)
              fmt.Fprintln(dockerCli.Out(), " System Time:", info.SystemTime)
              fmt.Fprintln(dockerCli.Out(), " EventsListeners:", info.NEventsListener)
          }

      以上是“docker中info命令請(qǐng)求流程分析”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

      另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。


      當(dāng)前標(biāo)題:docker中info命令請(qǐng)求流程分析-創(chuàng)新互聯(lián)
      網(wǎng)頁(yè)地址:http://www.ef60e0e.cn/article/jhpoj.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        渑池县| 长春市| 隆回县| 佛山市| 兴安盟| 辽阳市| 图木舒克市| 湟源县| 开封市| 庆阳市| 贵阳市| 离岛区| 介休市| 乐清市| 南京市| 屯昌县| 略阳县| 隆化县| 兴和县| 墨脱县| 怀化市| 无极县| 镇原县| 营口市| 钟祥市| 玛多县| 湘潭县| 富蕴县| 巴林右旗| 固安县| 永登县| 长沙市| 炎陵县| 玉门市| 全州县| 凭祥市| 常州市| 伊春市| 邳州市| 贵德县| 平武县|