Docker-compose命令详解
Define and run multi-container applications with Docker.
Usage:
docker-compose [-f=<arg>...] [options] [COMMAND] [ARGS...]
docker-compose -h|--help
Options:
-f, --file FILE Specify an alternate compose file (default: docker-compose.yml)
-p, --project-name NAME Specify an alternate project name (default: directory name)
--verbose Show more output
-v, --version Print version and exit
-H, --host HOST Daemon socket to connect to
--tls Use TLS; implied by --tlsverify
--tlscacert CA_PATH Trust certs signed only by this CA
--tlscert CLIENT_CERT_PATH Path to TLS certificate file
--tlskey TLS_KEY_PATH Path to TLS key file
--tlsverify Use TLS and verify the remote
--skip-hostname-check Don't check the daemon's hostname against the name specified
in the client certificate (for example if your docker host
is an IP address)
Commands:
build Build or rebuild services
config Validate and view the compose file
create Create services
down Stop and remove containers, networks, images, and volumes
events Receive real time events from containers
help Get help on a command
kill Kill containers
logs View output from containers
pause Pause services
port Print the public port for a port binding
ps List containers
pull Pulls service images
restart Restart services
rm Remove stopped containers
run Run a one-off command
scale Set number of containers for a service
start Start services
stop Stop services
unpause Unpause services
up Create and start containers
version Show the Docker-Compose version information
Options:
config
Usage: config [options]
当配置正确时,不输出任何内容,当文件配置错误,输出错误信息。
create
为服务创建容器.只是单纯的create,还需要使用start启动compose
Usage: create [options] [SERVICE...]
--force-recreate 重新创建容器,即使他的配置和镜像没有改变,不兼容--no-recreate参数
不兼容--force-recreate参数
--no-build 不创建镜像,即使缺失.
--build 创建容器前,生成镜像.
Usage: down [options]
--rmi type 删除镜像,类型必须是:
删除卷
attached to containers.
--remove-orphans Remove containers for services not defined in the
events
Usage: events [options] [SERVICE...]
{
"service": "web",
"event": "create",
"container": "213cf75fc39a",
"image": "alpine:edge",
"time": "2015-11-20T18:01:03.615550",
}
exec
Usage: exec [options] SERVICE COMMAND [ARGS...]
Options:
-d 分离模式,后台运行命令.
--privileged 获取特权.
--user USER 指定运行的用户.
-T 禁用分配TTY. By default `docker-compose exec`
docker-compose
exec web sh
kill
Usage: kill [options] [SERVICE...]
$ docker-compose kill -s SIGINT
logs
Usage: logs [options] [SERVICE...]
Options:
跟踪日志输出,就是可以实时查看日志
显示时间戳
从日志的结尾显示,--tail=200
pause
Usage: pause [SERVICE...]
unpause
Usage:
unpause [SERVICE...]
port
Usage: port [options] SERVICE PRIVATE_PORT
Options:
--protocol=proto tcp or udp [default: tcp]
--index=index index of the container if there are multiple
instances of a service [default: 1]
ps
Usage: ps [options] [SERVICE...]
Options:
-q 只显示ID
pull
Usage: pull [options] [SERVICE...]
push
Usage: push [options] [SERVICE...]
Options:
忽略错误.
restart
Usage: restart [options] [SERVICE...]
Options:
-t, --timeout TIMEOUT Specify a shutdown timeout in seconds. (default: 10)
rm
Usage: rm [options] [SERVICE...]
Options:
-a, --all Also remove one-off containers created by
By default, anonymous volumes attached to containers will not be removed. You can override this with Docker
.
volume ls
run
Usage: run [options] [-e KEY=VAL...] SERVICE [COMMAND] [ARGS...]
指定运行的用户
不启动link服务,只启动run的服务.
运行后删除容器,后台运行模式除外(-d).
开放端口
compose文件中配置什么端口,就映射什么端口.
T
禁用TTY.
设置工作目录
启动web服务器,并执行bash命令.
$ docker-compose run web bash
$ docker-compose run --service-ports web python manage.py shell
$ docker-compose run --publish 8080:80 -p 2022:22 -p 127.0.0.1:2021:21 web python manage.py shell
$ docker-compose run db psql -h db -U docker
不linke容器,单独启动指定容器:
$ docker-compose run --no-deps web python manage.py shell
scale
Usage: scale [SERVICE=NUM...]
$ docker-compose scale web=2 worker=
start
Usage: start [SERVICE...]
stop
Usage: stop [options] [SERVICE...]
Options:
up
Usage: up [options] [SERVICE...]
Options:
-d 后台运行,输出容器的名字.
Incompatible with --abort-on-container-exit.
--no-color 单色输出.
--no-deps 不启动link服务.
--force-recreate 强制重新创建compose服务,即使没有任何改变。重新创建后启动容器
Incompatible with --no-recreate.
--no-recreate 如果容器已经存在,不重新创建.
Incompatible with --force-recreate.
--no-build 不创建重启,即使镜像不存在.
--build 重新创建镜像,然后生成容器.
--abort-on-container-exit 任何容器停止,自动停止所有容器.
超时时间. (default: 10)
--remove-orphans 移除compose文件中未定义服务的容器
Docker-compose命令详解的更多相关文章
- 附003.Docker Compose命令详解
一 Docker Compose命令格式 Usage: docker-compose [-f <arg>...] [options] [COMMAND] [ARGS...] docker- ...
- 附005.Docker Compose文件详解
一 Docker Compose文件简介 compose文件使用yml格式,主要分为了四个区域: version:用于指定当前docker-compose.yml语法遵循哪个版本 services:服 ...
- Docker常用命令详解
docker ps 查看当前正在运行的容器 docker ps -a 查看所有容器的状态 docker start/stop id/name 启动/停止某个容器 docker attach id 进入 ...
- Docker Compose配置文件详解(V3)
Docker Compose配置文件是Docker Compose的核心,用于定义服务.网络和数据卷.格式为YAML,默认路径为./docker-compose.yml,可以使用.yml或.yaml扩 ...
- docker基础命令详解
Commands: attach Attach to a running container build Build an image from a Dockerfile commit ...
- 谁用光了磁盘?Docker System命令详解
译者按: Docker镜像,容器,数据卷以及网络都会占用主机的磁盘空间,这样的话,磁盘很容易就会被用完.这篇博客介绍了一个简单的解决方案 - Docker System命令. 原文: What's e ...
- Docker Compose 配置文件详解
先来看一份 docker-compose.yml 文件,不用管这是干嘛的,只是有个格式方便后文解说: version: '2' services: web: image: dockercloud/he ...
- Docker Compose文件详解 V2
Compose file reference 语法: web: build: ./web ports: - "5000:5000" volu ...
- Docker dockerfile命令详解
docker-file 官网文档:https://docs.docker.com/v17.09/engine/reference/builder/ 制作Dockerfile为Docker入门学习的第一 ...
- Docker(12)- docker run 命令详解
如果你还想从头学起 Docker,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1870863.html 作用 创建一个新的容器并运行一个 ...
随机推荐
- PHP 不使用第三个变量实现交换两个变量的值
//字符串版本 结合使用substr,strlen两个方法实现$a="a";$b="b";echo '交换前 $a:'.$a.',$b:'.$b.'<br ...
- 20145223《Java程序程序设计》实验一实验报告
实验一 Java开发环境的熟悉(Windows + IDE) 实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用IDE 编辑.编译.运行.调试Java程序. 实验步骤 (一)命令行下Ja ...
- 短信猫 TIdTCPServer TIdTCPClient
短信猫 服务端: IdTCPServer1: TIdTCPServer; IdAntiFreeze1: TIdAntiFreeze; unit UnitSever; interface uses Wi ...
- 遍历table指定name的td
$("td[name='rates']").each(function () { var temp = $(this).text().substr(0,$(this).text() ...
- 8VC Venture Cup 2016 - Final Round (Div. 2 Edition)
暴力 A - Orchestra import java.io.*; import java.util.*; public class Main { public static void main(S ...
- [转]使用 HTML5 IndexedDB API
本地数据持久性提高了 Web 应用程序可访问性和移动应用程序响应能力 索引数据库 (IndexedDB) API(作为 HTML5 的一部分)对创建具有丰富本地存储数据的数据密集型的离线 HTML5 ...
- An Unfair Game-[ACdream1035]
Problem Description There are n people and n target, everyone should get one target, no two people g ...
- BZOJ4607 : [PA2015 Final]Edycja
显然做完操作$2$后再做操作$1$. 建立一个$26$个点的有向图,每个点只有一条出边,$i$->$j$表示$i$最终变成了$j$,边权为一开始是$i$,最后不是$j$的位置个数,如果$i\ne ...
- VR教育旋风来袭,各大公司争先进军虚拟现实教育
根据国内一份最新的报告显示,VR技术对于提高学生的学习成绩有非常积极的作用,并且通过测试结果来看,无论是对知识的认知还是成绩测试,VR都起到了非常有效的效果. 2016成为VR元年,虚拟现实技术除了在 ...
- topcoder SRM 610 DIV2 TheMatrix
题目的意思是给一个01的字符串数组,让你去求解满足棋盘条件的最大棋盘 棋盘的条件是: 相邻元素的值不能相同 此题有点像求全1的最大子矩阵,当时求全1的最大子矩阵是用直方图求解的 本题可以利用直方图求解 ...