欢迎回来

登录 EAKE AI,继续您的智能之旅

忘记密码?
还没有账号?立即注册

Docker 容器管理 — 容器编排

Docker 容器管理 — 容器编排

管理 Docker 容器和镜像:启动/停止容器、查看日志、清理资源、镜像拉取和构建。

docker-manager

Simple management tool for Docker containers on Linux.

Installation

Install Docker Manager as global dependency:

# Yarn
sudo yarn global add docker-manager

# npm
sudo npm install -g docker-manager

Install the systemd service to enable auto start after boot:

sudo docker-manager install

If you wish to uninstall the systemd service, run:

sudo docker-manager uninstall

Terminology

Application

Applications are a collection of services that you would like to run. For example, a typical web application has two services, namely a backend and a frontend.

Services

Services are containers that you would like to run. Services are exactly the same as Docker Compose services.

Containers

Containers are runtime instances of an image. Containers are exactly the same as Docker containers.

Images

Images are exactly the same as Docker images.

Configuration

You can define applications in /srv/docker. These applications need to be defined in Docker Compose files. The folder structure should look like this:

/srv/docker
├── application1.yml
├── application2.yml
└── common.yml

The common.yml file is special and can be used to define common networks or volumes. It is required and is always included with other applications. Application definition files can have any name other than common.yml, for example /srv/docker/hello-world.yml.

Take a look at the example section below to see what these application definition files might look like.

Usage

Docker Manager CLI

docker-manager <command>

Commands:
  docker-manager install                                        Install systemd service
  docker-manager version                                        Displays version information
  docker-manager list                                           Lists applications
  docker-manager services <application>                         List services of an application
  docker-manager start <application> [services..]               Start an application
  docker-manager stop <application> [services..]                Stop an application
  docker-manager restart <application> [services..]             Restart an application
  docker-manager update <application> [services..]              Update an application
  docker-manager status <application> [services..]              Display status of an application           [aliases: ps]
  docker-manager top <application> [services..]                 Display running processes of an application
  docker-manager images <application> [services..]              Display images of an application
  docker-manager logs <application> [services..]                Display logs of an application
  docker-manager exec <application> <service> <command>         Execute a command in the container of a service
  [arguments..]
  docker-manager tokens                                         Lists tokens
  docker-manager create-token <name> <applications..>           Creates a token
  docker-manager delete-token <name>                            Deletes a token

Options:
  --version  Show version number                                                                               [boolean]
  --help     Show help                                                                                         [boolean]

Example

Configuration

/srv/docker
├── common.yml
└── hello-world.yml

The common.yml file:

version: '3'
networks:
    bridge:
        driver: bridge
        ipam:
            driver: default
            config:
                - subnet: 172.20.0.0/16

The hello-world.yml application definition file:

version: '3'
services:
    hello-world-backend:
        image: tutum/hello-world
        restart: unless-stopped
        networks:
            - bridge
    hello-world-frontend:
        image: tutum/hello-world
        restart: unless-stopped
        networks:
            - bridge

Management

# Start all applications
docker-manager start all

# Stop only the frontend service of the hello-world application
docker-manager stop hello-world hello-world-frontend

# Update all applications, this automatically services them if needed
docker-manager update all

# Display status of all services of hello-world
docker-manager status hello-world

# Display logs of the backend service of the hello-world application
docker-manager logs -f hello-world hello-world-backend

# Execute a command in the container of the backend service of the hello-world application
docker-manager exec hello-world hello-world-backend ls -alh
docker-manager exec hello-world hello-world-backend -e test=123 sh -c "echo \$test"

安装

# 安装到当前项目
npx skills add docker-manager

# 全局安装
npx skills add docker-manager -g

来源

安装指南

复制下方命令,在终端运行即可安装:

npx skills add docker-manager
npx skills add docker-manager -g
⚡ 一键安装到 GenHub

需已安装 GenHub 桌面端

使用指南

安装完成后,在对话框中直接使用此技能。

基本信息
作者 GenHub 分类 DevOps云 难度 Beginner 时长 1 hour
🛠️ 安装命令
npx skills add docker-manager
npx skills add docker-manager -g

评论已关闭。