人妖在线一区,国产日韩欧美一区二区综合在线,国产啪精品视频网站免费,欧美内射深插日本少妇

新聞動(dòng)態(tài)

docker 移除掉運(yùn)行不正常的container操作

發(fā)布日期:2021-12-25 05:40 | 文章來(lái)源:源碼中國(guó)

本菜鳥在剛學(xué)習(xí)docker的時(shí)候遇到了這樣的問(wèn)題,記錄一下,

當(dāng)啟動(dòng)一個(gè)container的時(shí)候,docker ps 看到剛啟動(dòng)的容器有問(wèn)題,

然后docker logs <container id> 才知道權(quán)限不夠,未能創(chuàng)建目錄。然后想啟動(dòng),但是當(dāng)前的container一直處于restarting ,然后docker stop 試了一下,返回成功,然后docker ps 當(dāng)前container 依然存在,然后docker kill的時(shí)候提示容器未啟動(dòng),docker -help 看了一下,docker rm 移除容器。

但改命令無(wú)法移除一個(gè)restarting 狀態(tài)的容器。

需要先docker stop<container id> 然后在docker rm 掉。

當(dāng)然 啟動(dòng)不成功也是因?yàn)闆](méi)有權(quán)限,docker 容器無(wú)權(quán)限 添加 --privileged=true 參數(shù) 。

在docker-compose的時(shí)候 docker-compose up會(huì)優(yōu)先使用已有的容器,而不是重新創(chuàng)建容器。需要帶上 --force-recreate 參數(shù)重新創(chuàng)建容器 docker-compose up -d --force-recreate

本人docker 菜鳥,記錄一下自己遇到的問(wèn)題,勿噴。

補(bǔ)充:Docker刪除大量停止的container

1. 怎么做

官方建議的批量刪除停止容器使用docker rm $(sudo docker ps -a -q)

千萬(wàn)不要用 docker rm -f $(sudo docker ps -a -q),會(huì)刪除全部容器的

2. 為什么這么做

1. docker ps -a -q

docker ps 命令的解釋:

docker ps -a -q 列出所有容器的數(shù)字ID
root@haha:~# docker ps --help
Usage: docker ps [OPTIONS]
List containers
Options:
 -a, --all       Show all containers (default shows just running)
 -f, --filter value  Filter output based on conditions provided (default [])
   --format string  Pretty-print containers using a Go template
   --help      Print usage
 -n, --last int    Show n last created containers (includes all states) (default -1)
 -l, --latest     Show the latest created container (includes all states)
   --no-trunc    Don‘t truncate output
 -q, --quiet      Only display numeric IDs
 -s, --size      Display total file sizes

具體看看,docker ps 是列出容器的命令

- a 列出所有的容器
- q 只顯示數(shù)字ID 

2. docker rm命令的解釋:

root@haha:~# docker rm --help
Usage: docker rm [OPTIONS] CONTAINER [CONTAINER...]
Remove one or more containers
Options:
 -f, --force   Force the removal of a running container (uses SIGKILL)
   --help   Print usage
 -l, --link   Remove the specified link
 -v, --volumes  Remove the volumes associated with the container

- f 強(qiáng)制刪除,可以刪除正在運(yùn)行的容器

- v 容器啟動(dòng)后,數(shù)據(jù)會(huì)以volumes的形式存在于硬盤中,即使刪除了container數(shù)據(jù)也不會(huì)刪除,加上這個(gè)參數(shù)那么容器執(zhí)行的數(shù)據(jù)也會(huì)被刪除

以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持本站。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。

版權(quán)聲明:本站文章來(lái)源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請(qǐng)保持原文完整并注明來(lái)源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非www.sddonglingsh.com所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來(lái)源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來(lái),僅供學(xué)習(xí)參考,不代表本站立場(chǎng),如有內(nèi)容涉嫌侵權(quán),請(qǐng)聯(lián)系alex-e#qq.com處理。

相關(guān)文章

實(shí)時(shí)開通

自選配置、實(shí)時(shí)開通

免備案

全球線路精選!

全天候客戶服務(wù)

7x24全年不間斷在線

專屬顧問(wèn)服務(wù)

1對(duì)1客戶咨詢顧問(wèn)

在線
客服

在線客服:7*24小時(shí)在線

客服
熱線

400-630-3752
7*24小時(shí)客服服務(wù)熱線

關(guān)注
微信

關(guān)注官方微信
頂部