- 常用选项
build Build or rebuild servicesbundle Generate a Docker bundle from the Compose fileconfig Validate and view the Compose filecreate Create servicesdown Stop and remove containers, networks, images, and volumesevents Receive real time events from containersexec Execute a command in a running containerhelp Get help on a commandimages List imageskill Kill containerslogs View output from containerspause Pause servicesport Print the public port for a port bindingps List containerspull Pull service imagespush Push service imagesrestart Restart servicesrm Remove stopped containersrun Run a one-off commandscale Set number of containers for a servicestart Start servicesstop Stop servicestop Display the running processesunpause Unpause servicesup Create and start containersversion Show the Docker-Compose version information例子: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容器
- 强制重建
docker-compose up -d --force-recreate
参考网址:https://www.cnblogs.com/moxiaoan/p/9299404.html