Docker-compose常用命令

1.github地址:https://github.com/TodorText/lnmp.git

这个是根据laradock精简的lnmp,并且摘除了从容器挂载数据卷

2.命令

docker-compose --help你会看到如下这么多命令

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

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

  

3.常用命令

docker-compose up -d nginx                     构建建启动nignx容器

docker-compose exec nginx bash            登录到nginx容器中

docker-compose down                              删除所有nginx容器,镜像

docker-compose ps                                   显示所有容器

docker-compose restart nginx                   重新启动nginx容器

docker-compose run --no-deps --rm php-fpm php -v  在php-fpm中不启动关联容器,并容器执行php -v 执行完成后删除容器

docker-compose build nginx                     构建镜像 。        

docker-compose build --no-cache nginx   不带缓存的构建。

docker-compose logs  nginx                     查看nginx的日志 

docker-compose logs -f nginx                   查看nginx的实时日志

 

docker-compose config  -q                        验证(docker-compose.yml)文件配置,当配置正确时,不输出任何内容,当文件配置错误,输出错误信息。 

docker-compose events --json nginx       以json的形式输出nginx的docker日志

docker-compose pause nginx                 暂停nignx容器

docker-compose unpause nginx             恢复ningx容器

docker-compose rm nginx                       删除容器(删除前必须关闭容器)

docker-compose stop nginx                    停止nignx容器

docker-compose start nginx                    启动nignx容器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值