Files
linux-wiki/content/小白手册/服务器日常/docker.md
2021-10-21 15:13:29 +08:00

73 lines
1.5 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "docker使用笔记"
date: 2021-10-18T16:59:28+08:00
draft: false
---
基础
`docker ps -a` 查看容器列表
`docker ps `查看正在运行的容器
`exit` 退出容器
`docker start <docker container id>` 启动一个已停止的容器
`docker stop <容器id>`停止容器
`docker restart <容器id>`重启容器
```bash
进入容器的两个命令
exec命名
docker exec -it <容器id> /bin/bash
attach命令退出后会终止容器
docker attach <容器id>
```
`docker rm -f <容器id>`删除容器
---------------------------------------------------------
进阶
`docker container prune`删除所有容器
> 镜像操作
>
> `docker images`列出本机镜像
>
> ```bash
> rocket.chat <none> 30f3e81eb8ad 6 months ago 816MB
> rocket.chat <none> 077d87f42281 6 months ago 816MB
> rocket.chat <none> 666b6ddfd746 6 months ago 816MB
> rocket.chat 3.10.5 63bd37a1c5e9 8 months ago 816MB
> mongo 4.0 5323653a5708 8 months ago 427MB
> cppla/serverstatus latest 84b2fc1b9a79 15 months ago 133MB
>
> ```
>
> `docker run -t -i mongo:4.0 /bin/bash`使用mongo4.0运行容器不加tag默认latest
>
> `docker search [容器名]`寻找镜像
>
> `docker pull [容器名]`下载容器镜像
>
> `docker rmi [容器名]`删除镜像
> 映射操作
>
> 端口映射
>
> docker run -d -P [image] [command]
>
>