怎么在Docker中使用Compose命令?很多新手對(duì)此不是很清楚,為了幫助大家解決這個(gè)難題,下面小編將為大家詳細(xì)講解,有這方面需求的人可以來學(xué)習(xí)下,希望你能有所收獲。
我們提供的服務(wù)有:成都網(wǎng)站制作、網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、邳州ssl等。為近1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的邳州網(wǎng)站制作公司
1.Docker compose的使用非常類似于docker命令的使用,但是需要注意的是大部分的compose命令都需要到docker-compose.yml文件所在的目錄下才能執(zhí)行。
2.compose以守護(hù)進(jìn)程模式運(yùn)行加-d選項(xiàng)
$ docker-compose up -d
3.查看有哪些服務(wù),使用docker-compose ps命令,非常類似于 docker 的ps命令

4.查看compose日志
$ docker-compose logs web $ docker-compose logs redis
5.停止compose服務(wù)
$ docker-compose stop $ docker-compose ps

看到服務(wù)的狀態(tài)為Exit退出狀態(tài)
6.重啟compose服務(wù)
$ docker-compose restart $ docker-compose ps

7.kill compose服務(wù)
$ docker-compose kill $ docker-compose ps

狀態(tài)碼為137
8.刪除compose服務(wù)
$ docker-compose rm

9.更多的docker-compose命令可以使用docker-compose --help查看
docker-compose --help你會(huì)看到如下這么多命令
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
docker-compose up -d nginx 構(gòu)建建啟動(dòng)nignx容器
docker-compose exec nginx bash 登錄到nginx容器中
docker-compose down 刪除所有nginx容器,鏡像
docker-compose ps 顯示所有容器
docker-compose restart nginx 重新啟動(dòng)nginx容器
docker-compose run --no-deps --rm php-fpm php -v 在php-fpm中不啟動(dòng)關(guān)聯(lián)容器,并容器執(zhí)行php -v 執(zhí)行完成后刪除容器
docker-compose build nginx 構(gòu)建鏡像 。
docker-compose build --no-cache nginx 不帶緩存的構(gòu)建。
docker-compose logs nginx 查看nginx的日志
docker-compose logs -f nginx 查看nginx的實(shí)時(shí)日志
docker-compose config -q 驗(yàn)證(docker-compose.yml)文件配置,當(dāng)配置正確時(shí),不輸出任何內(nèi)容,當(dāng)文件配置錯(cuò)誤,輸出錯(cuò)誤信息。
docker-compose events --json nginx 以json的形式輸出nginx的docker日志
docker-compose pause nginx 暫停nignx容器
docker-compose unpause nginx 恢復(fù)ningx容器
docker-compose rm nginx 刪除容器(刪除前必須關(guān)閉容器)
docker-compose stop nginx 停止nignx容器
docker-compose start nginx 啟動(dòng)nignx容器
看完上述內(nèi)容是否對(duì)您有幫助呢?如果還想對(duì)相關(guān)知識(shí)有進(jìn)一步的了解或閱讀更多相關(guān)文章,請(qǐng)關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝您對(duì)創(chuàng)新互聯(lián)的支持。
名稱欄目:怎么在Docker中使用Compose命令
文章鏈接:http://chinadenli.net/article46/jigghg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站制作、App設(shè)計(jì)、全網(wǎng)營(yíng)銷推廣、關(guān)鍵詞優(yōu)化、外貿(mào)建站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)