docker的常用命令
镜像命令
root@MiWiFi-R4CM-srv ~]
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
mysql MySQL is a widely used, open-source relation… 11498 [OK]
mariadb MariaDB Server is a high performing open sou… 4363 [OK]
下载命令
Using default tag: latest
latest: Pulling from library/mysql
07aded7c29c6: Pull complete
f68b8cbd22de: Pull complete
30c1754a28c4: Pull complete
1b7cb4d6fe05: Pull complete
79a41dc56b9a: Pull complete
00a75e3842fb: Pull complete
b36a6919c217: Pull complete
635b0b84d686: Pull complete
6d24c7242d02: Pull complete
5be6c5edf16f: Pull complete
cb35eac1242c: Pull complete
a573d4e1c407: Pull complete
Digest: sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213d
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest
**删除命令**
容器命令
新建容器并启用
列出所有运行的容器
-a
-n
-q
退出容器
Ctrl + P + Q 容器不停止退出
删除容器
启动和停止容器的操作
常用其它命令
后台启动容器
查看日志
```shell
[root@MiWiFi-R4CM-srv ~]
Usage: docker logs [OPTIONS] CONTAINER
Fetch the logs of a container
Options:
--details Show extra details provided to logs
-f, --follow Follow log output
--since string Show logs since timestamp (e.g. 2013-01-02T13:23:37Z) or relative
(e.g. 42m for 42 minutes)
-n, --tail string Number of lines to show from the end of the logs (default "all")
-t, --timestamps Show timestamps
--until string Show logs before a timestamp (e.g. 2013-01-02T13:23:37Z) or relative
(e.g. 42m for 42 minutes)
查看镜像的元数据
进入当前正在运行的容器
从容器内拷贝文件到主机
小结
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container changes
cp Copy files/ folders from the containers filesystem to the host path
create create a new container
diff Inspect changes on a container' s filesystem
events Get real time events from the server
exec Run a command in an existing container
export Stream the contents of a container as a tar archive
history Show the history of an image
images list Images
import Create a new filesystem image from the contents of a tarba11
info Display system-wide information
inspect Return low- level information on a container
kill Kill a running container
load Load an image from a tar archive
login Register or Login to the docker registry server
logout Log out from a Docker registry server
logs Fetch the logs of a container
port Lookup the public-facing port which is NAT-ed to PRIVATE_PORT
pause Pause all processes within a container
ps List containers
pull Pull an image or a repository from the docker registry server
push Push an image or a repository to the docker registry server
restart Restart a running container
rm Remove one or more containers
rmi Remove one or more Images
run Run a command in a new container
save Save an image to a tar archive
search Search for an image on the Docker Hub
start Start a stopped containers
stop Stop a running containers
tag Tag an Image into a repos tory
top Lookup the running processes of a container
unpause Unpause a paused container
version Show the docker version information
wait Block until a container stops, then print its exit code
|