夫陶公清风千古,余又何人,敢称庶几

文章目录

  • 简介
  • 命令
    • docker-compose ps
    • docker-compose up
    • docker-compose down
    • docker-compose logs
    • docker-compose build
    • docker-compose port
    • docker-compose rm
    • docker-compose restart
    • docker-compose start
    • docker-compose config
    • docker-compose stop
    • docker-compose kill

简介

- :表示缩写
–:表示全称

命令

docker-compose ps

Lists containers.
显示所有容器

原文:

Usage: ps [options] [SERVICE...]Options:-q, --quiet          Only display IDs--services           Display services--filter KEY=VAL     Filter services by a property-a, --all            Show all stopped containers (including those created by the run command)

翻译:

 使用方法:ps [选项] [服务…]选项:-q, --quiet          只显示所有容器的ID--services           显示所有服务--filter KEY=VAL     通过属性筛选服务-a, --all            显示所有已停止的容器(包括由run命令创建的容器)

案例:

事先运行容器 :
[root@VM-0-11-centos tomcat]# ls
docker-compose.yml
[root@VM-0-11-centos tomcat]# docker-compose up -d

  1. 无选项
[root@VM-0-11-centos tomcat]# docker-compose psName        Command       State           Ports
---------------------------------------------------------
tomcat   catalina.sh run   Up      0.0.0.0:8080->8080/tcp
  1. -q, --quiet
[root@VM-0-11-centos tomcat]# docker-compose ps -q
f4dd5f5aefb284907de492e0aef881b4e6a5ec51fb5437850ce6cbdaf672ee4a[root@VM-0-11-centos tomcat]# docker-compose ps --quiet
f4dd5f5aefb284907de492e0aef881b4e6a5ec51fb5437850ce6cbdaf672ee4a
  1. –filter KEY=VAL

  2. -a,–all

[root@VM-0-11-centos tomcat]# docker-compose ps -aName         Command       State           Ports
----------------------------------------------------------
tomcat2   catalina.sh run   Up      0.0.0.0:8082->8080/tcp[root@VM-0-11-centos tomcat]# docker-compose ps --allName         Command       State           Ports
----------------------------------------------------------
tomcat2   catalina.sh run   Up      0.0.0.0:8082->8080/tcp

docker-compose up

Builds, (re)creates, starts, and attaches to containers for a service.
构建、(重新)创建、启动和附加到服务容器上。

原文:

Usage: up [options] [--scale SERVICE=NUM...] [SERVICE...]Options:-d, --detach               Detached mode: Run containers in the background,print new container names. Incompatible with--abort-on-container-exit.--no-color                 Produce monochrome output.--quiet-pull               Pull without printing progress information--no-deps                  Don't start linked services.--force-recreate           Recreate containers even if their configurationand image haven't changed.--always-recreate-deps     Recreate dependent containers.Incompatible with --no-recreate.--no-recreate              If containers already exist, don't recreatethem. Incompatible with --force-recreate and --renew-anon-volumes.--no-build                 Don't build an image, even if it's missing.--no-start                 Don't start the services after creating them.--build                    Build images before starting containers.--abort-on-container-exit  Stops all containers if any container wasstopped. Incompatible with --detach.--attach-dependencies      Attach to dependent containers.-t, --timeout TIMEOUT      Use this timeout in seconds for containershutdown when attached or when containers arealready running. (default: 10)-V, --renew-anon-volumes   Recreate anonymous volumes instead of retrievingdata from the previous containers.--remove-orphans           Remove containers for services not definedin the Compose file.--exit-code-from SERVICE   Return the exit code of the selected servicecontainer. Implies --abort-on-container-exit.--scale SERVICE=NUM        Scale SERVICE to NUM instances. Overrides the`scale` setting in the Compose file if present.

翻译:

使用方法: up [选项] [--scale SERVICE=NUM...] [SERVICE...]选项:-d, --detach               附加模式:在后台运行容器,打印新的容器名称。不兼容——abort-on-container-exit。--no-color                 以单色输出--quiet-pull               拉取而不打印进度信息--no-deps                  不启动链接服务--force-recreate           即使容器的配置和镜像没有改变, 容器也要重新被创建--always-recreate-deps     重新创建容器的依赖,不兼容——no-recreate--no-recreate              如果容器已经存在,不要重新创建它们。-force-和-renew-anon-volumes不兼容。--no-build                 不要构建一个镜像,即使它缺失--no-start                 创建服务后不要启动它们--build                    在启动容器之前构建镜像--abort-on-container-exit  如果任何容器被停止,则停止所有容器。与--detach不兼容--attach-dependencies      附加到依赖容器-t, --timeout TIMEOUT      当附加容器或容器已经在运行时,使用此超时(以秒为单位)用于关闭容器。(默认值:10)-V, --renew-anon-volumes   重新创建匿名数据卷,而不是从以前的容器检索数据--remove-orphans           删除Compose文件中未定义的服务容器。--exit-code-from SERVICE   返回所选服务容器的退出代码。意味着——abort-on-container-exit。--scale SERVICE=NUM        将服务扩展到NUM实例。如果存在,将覆盖Compose文件中的“scale”设置。

案例:

  1. 无选项

  1. —no-color

docker-compose down

Stops containers and removes containers, networks, volumes, and images created by up.
停止容器并删除up创建的容器、网络、数据卷和镜像。

原文:

Usage: down [options]Options:--rmi type              Remove images. Type must be one of:'all': Remove all images used by any service.'local': Remove only images that don't have acustom tag set by the `image` field.-v, --volumes           Remove named volumes declared in the `volumes`section of the Compose file and anonymous volumesattached to containers.--remove-orphans        Remove containers for services not defined in theCompose file-t, --timeout TIMEOUT   Specify a shutdown timeout in seconds.(default: 10)

翻译:

用法:down[选项]
选项:--rmi type              删除镜像。类型必须是以下之一:'all':删除任何服务使用的所有镜像。'local':只删除没有' image '字段设置的自定义标签的图像。-v, --volumes           删除在Compose文件的' volumes '部分声明的命名卷和附加到容器上的匿名卷。--remove-orphans        删除在Compose文件中未定义的服务容器-t, --timeout TIMEOUT   指定关机超时时间(以秒为单位)。( 默认值:10)

案例:

  1. –rmi type
[root@VM-0-11-centos tomcat]# docker-compose down --rmi all
Stopping tomcat2 ... done
Removing tomcat2 ... done
Removing network tomcat_default
Removing image tomcat:7.0.57
[root@VM-0-11-centos tomcat]# docker-compose ps
Name   Command   State   Ports
------------------------------
  1. 无选项
[root@VM-0-11-centos tomcat]# docker-compose down
Stopping tomcat2 ... done
Removing tomcat2 ... done
Removing network tomcat_default
[root@VM-0-11-centos tomcat]# docker-compose ps
Name   Command   State   Ports
------------------------------

docker-compose logs

Displays log output from services.
显示服务的日志输出。

原文:

Usage: logs [options] [SERVICE...]Options:--no-color          Produce monochrome output.-f, --follow        Follow log output.-t, --timestamps    Show timestamps.--tail="all"        Number of lines to show from the end of the logsfor each container.

翻译:

Usage: logs [options] [SERVICE...]Options:--no-color          产生单色输出。-f, --follow        遵循日志输出-t, --timestamps    显示时间戳。--tail="all"       从每个容器的日志末尾开始显示行数。

案例:

  1. 无选项

  1. –no-color

  1. -t, --timestamps

  1. –tail=“all”

docker-compose build

Services are built once and then tagged, by default as project_service. For example, composetest_db. If the Compose file specifies an image name, the image is tagged with that name, substituting any variables beforehand. See variable substitution.
If you change a service’s Dockerfile or the contents of its build directory, run docker-compose build to rebuild it.
服务只构建一次,然后被标记,默认为project_service。例如,composetest_db。如果Compose文件指定了一个镜像名称,则该镜像将使用该名称进行标记,并预先替换任何变量。看到变量替换。
如果你改变了一个服务的Dockerfile或者它的构建目录的内容,运行docker-compose build来重建它。

原文:

Usage: build [options] [--build-arg key=val...] [SERVICE...]Options:--build-arg key=val     Set build-time variables for services.--compress              Compress the build context using gzip.--force-rm              Always remove intermediate containers.-m, --memory MEM        Set memory limit for the build container.--no-cache              Do not use cache when building the image.--no-rm                 Do not remove intermediate containers after a successful build.--parallel              Build images in parallel.--progress string       Set type of progress output (`auto`, `plain`, `tty`).--pull                  Always attempt to pull a newer version of the image.-q, --quiet             Don't print anything to `STDOUT`.

翻译:

使用方法: build [选项] [--build-arg key=val...] [SERVICE...]选项:--build-arg key=val     为服务设置构建时变量。--compress              使用gzip压缩构建上下文。--force-rm              始终移除中间容器-m, --memory MEM        为构建容器设置内存限制。--no-cache              在构建镜像时不要使用缓存。--no-rm                 在成功构建之后,不要删除中间容器。--parallel              并行构建映像。--progress string       设置进度输出类型(' auto ', ' plain ', ' tty ')。--pull                  总是尝试拉出一个新版本的镜像。-q, --quiet             不要打印任何东西到' STDOUT '。

案例:

  1. List item

  2. List item

  3. List item

  4. List item

  5. List item

docker-compose port

Prints the public port for a port binding.
打印端口绑定的公共端口。

原文:

Usage: port [options] SERVICE PRIVATE_PORTOptions:--protocol=proto  tcp or udp [default: tcp]--index=index     index of the container if there are multipleinstances of a service [default: 1]

翻译:

使用方法:port [选项] SERVICE PRIVATE_PORT选项:--protocol=proto  tcp或udp[默认值:tcp]--index=index     如果服务有多个实例,则为容器索引[默认值:1]

案例:

  1. 无选项

  2. –protocol=proto

  3. –index=index

docker-compose rm

Removes stopped service containers.
移除停止服务容器。

原文:

Usage: rm [options] [SERVICE...]Options:-f, --force   Don't ask to confirm removal-s, --stop    Stop the containers, if required, before removing-v            Remove any anonymous volumes attached to containers-a, --all     Deprecated - no effect.

翻译:

Usage: rm [options] [SERVICE...]Options:-f, --force   强制删除-s, --stop    如果需要,在删除容器之前,停止容器-v            删除任何附加到容器上的匿名数据卷-a, --all     弃用 - no effect.

案例:

  1. -f, --force

  2. -s, --stop

[root@VM-0-11-centos tomcat]# docker-compose rm -s
Stopping tomcat2 ... done
Going to remove tomcat2
Are you sure? [yN] y
Removing tomcat2 ... done
  1. -v

  2. -a, --all

docker-compose restart

Restarts all stopped and running services.
重启所有已停止和正在运行的服务。

原文:

Usage: restart [options] [SERVICE...]Options:-t, --timeout TIMEOUT      Specify a shutdown timeout in seconds.(default: 10)

翻译:

使用方法: restart [选项] [SERVICE...]选项:-t, --timeout TIMEOUT      指定关机超时时间(以秒为单位)。(默认值:10)

案例:

  1. 无选项
[root@VM-0-11-centos tomcat]# docker-compose psName         Command       State           Ports
----------------------------------------------------------
tomcat2   catalina.sh run   Up      0.0.0.0:8082->8080/tcp
[root@VM-0-11-centos tomcat]# docker-compose restart
Restarting tomcat2 ... done
[root@VM-0-11-centos tomcat]# docker-compose psName         Command       State           Ports
----------------------------------------------------------
tomcat2   catalina.sh run   Up      0.0.0.0:8082->8080/tcp
  1. -t, --timeout TIMEOUT
[root@VM-0-11-centos tomcat]# docker-compose restart -t 2
Restarting tomcat2 ... done

docker-compose start

Starts existing containers for a service.
启动已经存在容器的服务。

原文:

Usage: start [SERVICE...]

翻译:

使用方法: start [SERVICE...]

案例:

  1. List item

  2. List item

  3. List item

  4. List item

  5. List item

docker-compose config

Validate and view the Compose file.
验证并查看Compose文件。

原文:

Usage: config [options]Options:--resolve-image-digests  Pin image tags to digests.--no-interpolate         Don't interpolate environment variables.-q, --quiet              Only validate the configuration, don't printanything.--services               Print the service names, one per line.--volumes                Print the volume names, one per line.--hash="*"               Print the service config hash, one per line.Set "service1,service2" for a list of specified servicesor use the wildcard symbol to display all services.

翻译:

Usage: config [options]Options:--resolve-image-digests  Pin镜像标签到摘要。--no-interpolate         不插入环境变量。-q, --quiet              只验证配置,不打印任何东西。--services               打印服务名,每行一个。--volumes                打印数据卷名,每行一个。--hash="*"               打印服务配置散列,每行一个。为指定的服务列表设置“service1,service2”,或使用通配符来显示所有服务。

案例:

  1. 无选项

  2. –resolve-image-digests

  3. -q, --quiet

  4. –services

  5. –volumes

  6. –hash="*"

docker-compose stop

Stops running containers without removing them. They can be started again with docker-compose start.
停止运行容器而不移除它们。它们可以通过docker-compose start重新启动。

原文:

Usage: stop [options] [SERVICE...]Options:-t, --timeout TIMEOUT      Specify a shutdown timeout in seconds.(default: 10)

翻译:

使用方法: stop [选项] [SERVICE...]选项:-t, --timeout TIMEOUT      指定关机超时时间(以秒为单位)。(默认值:10)

案例:

  1. List item

  2. List item

  3. List item

  4. List item

  5. List item

docker-compose kill

Forces running containers to stop by sending a SIGKILL signal. Optionally the signal can be passed, for example:
通过发送SIGKILL信号来强制运行容器停止。可选的信号可以被传递,例如:
docker-compose kill -s SIGINT

原文:

Usage: kill [options] [SERVICE...]Options:-s SIGNAL         SIGNAL to send to the container.Default signal is SIGKILL.

翻译:

使用方法: kill [选项] [SERVICE...]选项:-s SIGNAL         发送信号给容器。默认信号是SIGKILL。

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

原文:

翻译:

案例:

docker-compose命令介绍和使用【官方英文文档翻译】【附加案例】相关推荐

  1. Docker Compose学习之docker-compose.yml编写规则 及 实战案例

    [Docker那些事]系列文章 docker 安装 与 卸载 centos Dockerfile 文件结构.docker镜像构建过程详细介绍 Dockerfile文件中CMD指令与ENTRYPOINT ...

  2. Docker Compose基本介绍

    Docker Compose 什么是docker compose 1. Compose是一个定义和管理多容器的工具,使用Python语言编写. 2. 使用Compose配置文件描述多个容器应用的架构, ...

  3. Docker拉取Mysql镜像并启动访问及docker常用命令介绍

    上篇文章介绍了 Centos7安装docker并修改成阿里云镜像源地址 可以参考使用: https://blog.csdn.net/weixin_44232093/article/details/12 ...

  4. Docker Compose 命令详解

    一.docker-compose命令对象与格式 二.命令选项 三.命令使用说明 build 构建(重新构建)项目中的服务容器 config 检测compose文件的错误 up 启动服务 down 停止 ...

  5. Docker Compose 网络介绍

    https://www.cnblogs.com/mi12205599/p/10919346.html 转载于:https://www.cnblogs.com/baiqian/p/10921291.ht ...

  6. .NET遇上Docker - 使用Docker Compose组织Ngnix和.NETCore运行

    本文工具准备: Docker for Windows Visual Studio 2015 与 Visual Studio Tools for Docker 或 Visual Studio 2017 ...

  7. Docker基础、利用Docker Compose部署Vue项目

    前言 最近,接触了Docker,写一个笔记记录一下学习的成果.参考了docker官网和一个b站老师的讲解教程Docker快速上手教程,受益良多! 一.Docker安装和重要概念 1.安装docker ...

  8. Docker与Docker Compose的安装以及Portainer容器管理工具

    Docker官网 概述 Docker 是一个用于开发.发布和运行应用程序的开放平台.Docker 能够将应用程序与基础架构分离,以便可以快速交付软件.使用 Docker,可以像管理应用程序一样管理基础 ...

  9. 04@Docker Compose安装Compose模板文件的使用

    文章目录 Docker Compose 一.Docker Compose的介绍 1.Compose概述 2.Docker与Docker Compose区别 二.Docker Compose的安装 1. ...

最新文章

  1. 搜索引擎是如何判断网站质量的?
  2. IsDlgButtonChecked()
  3. 最小的JavaFX演示文稿(在JavaFX中)
  4. 解决导入myeclipse的项目注释和中文是乱码
  5. 读取遥感图像中遇到的问题集锦
  6. python 从数据库 提取数据 生成html_python如何将数据生成html文件+浏览器中文显示乱码问题...
  7. ECharts-第一篇最简单的应用
  8. JS常用事件兼容性处理方法
  9. Backup Exec启动时,系统报“CLR20r3“错误
  10. MySQL免安装版本的配置
  11. ubuntu系统启动项的修改
  12. IT培训行业揭秘(四)
  13. 解决:java.lang.IllegalStateExceptio:Underflow in restore - more restores than saves异常,Module闪退
  14. 程序员自爆奇葩入职原因:进腾讯是为了不用续费年费会员,进抖音是想天天上班刷抖音
  15. NLP中的attention机制总结
  16. Android四大组件之Activity(intent、ActivityThread)
  17. python定义匿名函数关键字_Python匿名函数
  18. drupal安装教程mysql_Drupal7安装完整教程
  19. 1、TomcatHttp协议
  20. 聊聊答题应用题库的建立

热门文章

  1. Unity3D(UE4)加载倾斜摄影数据OSGB格式
  2. 关于通过dll导出类模板和函数模板
  3. 借助钉钉宜搭,奶茶店开始用黑科技管理门店了
  4. “控本焦虑”的工程企业 用钉钉宜搭找到了低成本数字化的“捷径”
  5. Android网络性能监控方案
  6. MongoDB sharding 集合不分片性能更高?
  7. Objective-C中的associated object释放时机问题
  8. 阿里云马劲:保证云产品持续拥有稳定性的实践和思考 1
  9. Mac 神兵利器(三) 使用Intellij IDEA打造全栈IDE
  10. 阿里云ECS家族再添新成员,推出密集计算型实例规格族ic5