码迷,mamicode.com
首页 > 其他好文 > 详细

(四)Docker三剑客之Compose

时间:2018-08-04 17:23:05      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:list   not   The   art   lin   process   only   man   -name   

参考:

1. 下载安装

curl -L https://github.com/docker/compose/releases/download/1.17.1/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

cd /usr/local/bin/
chmod +x docker-compose

2. 启动

mkdir compose
cd compose/
vim docker-compose.yml

docker-compose up

docker-compose.yml

version: ‘3‘
services:
    redis:
        image: "redis:latest"

3. docker-compose help

[root@Thor compose]# docker-compose help
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
  --no-ansi                   Do not print ANSI control characters
  -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)
  --project-directory PATH    Specify an alternate working directory
                              (default: the path of the Compose file)

Commands:
  build              Build or rebuild services
  bundle             Generate a Docker bundle from the Compose file
  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
  exec               Execute a command in a running container
  help               Get help on a command
  images             List images
  kill               Kill containers
  logs               View output from containers
  pause              Pause services
  port               Print the public port for a port binding
  ps                 List containers
  pull               Pull service images
  push               Push 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
  top                Display the running processes
  unpause            Unpause services
  up                 Create and start containers
  version            Show the Docker-Compose version information
[root@Thor compose]# 

4. 启动项目中的服务(容器)

[root@Thor compose]# docker-compose start redis
Starting redis ... done

[root@Thor compose]# docker-compose ps
     Name                    Command               State    Ports  
-------------------------------------------------------------------
compose_redis_1   docker-entrypoint.sh redis ...   Up      6379/tcp
[root@Thor compose]#

5. docker-compose exec

[root@Thor compose]# docker-compose exec redis bash
root@883179463cd2:/data# redis-cli
127.0.0.1:6379> keys *
1) "name"
127.0.0.1:6379> 
127.0.0.1:6379> 

(四)Docker三剑客之Compose

标签:list   not   The   art   lin   process   only   man   -name   

原文地址:https://www.cnblogs.com/walkinginthesun/p/9419072.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!