docker-compose命令介绍和使用【官方英文文档翻译】【附加案例】
夫陶公清風千古,余又何人,敢稱庶幾
文章目錄
- 簡介
- 命令
- 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
–filter KEY=VAL
-a,–all
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”設置。案例:
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)案例:
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" 從每個容器的日志末尾開始顯示行數。案例:
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 '。案例:
List item
List item
List item
List item
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]案例:
無選項
–protocol=proto
–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.案例:
-f, --force
-s, --stop
-v
-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)案例:
docker-compose start
Starts existing containers for a service.
啟動已經存在容器的服務。
原文:
Usage: start [SERVICE...]翻譯:
使用方法: start [SERVICE...]案例:
List item
List item
List item
List item
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”,或使用通配符來顯示所有服務。案例:
無選項
–resolve-image-digests
-q, --quiet
–services
–volumes
–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)案例:
List item
List item
List item
List item
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命令介绍和使用【官方英文文档翻译】【附加案例】的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 前端_网页编程 节流
- 下一篇: 一键快速生成 Vue 的 HTML页面结