Docker實戰之鏡像和容器的基本操作(二)

1. 鏡像

查看鏡像

docker image

搜索鏡像

docker search redis

拉取鏡像

docker pull image

配置docker鏡像加速:

sudo mkdir -p /etc/docker
sudo vi /etc/docker/daemon.json
{
“registry-mirrors”: [“https://l10nt4hq.mirror.aliyuncs.com”]
}
sudo systemctl daemon-reload
sudo systemctl restart docker

刪除鏡像

docker rmi 鏡像id

注意:刪除所有鏡像

docker rmi docker images -q


2. 容器

查看容器

查看正在運行的容器

[root@localhost ~]$ docker ps

查看所有容器(包擴歷史啓動的容器)

[root@localhost ~]$ docker ps -a

查看最後一次運行的容器

[root@localhost ~]$ docker ps -l

查看停止的容器

[root@localhost ~]$ docker ps -f status=exited

操作容器

1創建交互式容器 1

[root@localhost ~]$ docker run -it --name=myredis redis:4.0.0 

創建守護模式的容器

[root@localhost ~]$ docker run -di --name=redis redis:4.0.0

關閉容器

[root@localhost ~]$ docker start --name名稱
[root@localhost ~]$ docker stop --name名稱
[root@localhost ~]$ docker stop $(docker ps -qa) `關閉所有容器`

刪除容器

[root@localhost ~]$ docker rm --name名稱
[root@localhost ~]$ docker rm $(docker ps -qa) `關閉所有容器

查看容器ip

[root@localhost ~]$ docker inspect --name名稱

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章