只会一点点 ubuntu, 其他的不会,以ubuntu 16.04为例
- 查看所有容器,不管容器是否运行
docker ps -a - 查看所有镜像
docker images [options]
options:
2.1 可以是 pepository 镜像的名称
2.2 --no-trunc : 可以查看到详细的 image id
2.3 -q : 简单查看 image id
2.4 -a : 所有 image - 创建并运行 docker 容器
3.1 docker run -i -t -d --name=ubuntu16 ubuntu:16.04 "/bin/bash"
-i : 可以输入进行交互
-t : 终端交互
--name : 设置容器名称 ubuntu16
ubuntu:16.04 : 指定使用镜像和版本
"/bin/bash" 指定容器启动使用的应用
-i -t -d 可以写成 -itd
3.2 docker run -d -p 8090:22 --name ubuntu-ssh-a1 ubuntu16:latest /usr/sbin/sshd -D
-p : 指定 8090 端口对应 22 端口
ubuntu16:latest : 镜像版本
/usr/sbin/sshd -D : 命令启动 - [启动|运行]/停止容器
docker start/stop [options]
options:
4.1 container id 容器的id, 多个使用空格分开
4.2 names 容器的名称, 多个使用空格分开 - 删除容器,需要先将容器先停止才能删除
docker rm [container id 容器的id 或 names 多个使用空格分开] - 删除镜像,最好删除的镜像是没有容器使用或废弃
docker rmi [pepository 或 image id 多个使用空格分开] - 进去容器,容器需要运行中
docker exec -it param-1 params-2
param-1 : container id 容器的id 或 name
param-2 : command 的命令, docker ps 可以查看到 command 的内容 - 查看容器日志,有的时候可以看到一些日志
docker logs [container id 容器的id 或 name]
网友评论