标签:rgs hup work get sql arc 显示 proc target
# 显示docker的版本信息
docker version
# 显示docker的系统信息
docker info
# 帮助命令
docker 命令 --help
[root@VM-0-13-centos /]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
busybox latest 491198851f0c 7 days ago 1.23MB
redis latest 621ceef7494a 6 weeks ago 104MB
postgres latest acf5fb8bfd76 6 weeks ago 314MB
hello-world latest bf756fb1ae65 14 months ago 13.3kB
sentry latest fe6992de61df 16 months ago 869MB
REPOSITORY | TAG | IMAGE ID | CREATED | SIZE |
---|---|---|---|---|
镜像的仓库源 | 镜像的标签 | 镜像的id | 镜像的创建时间 | 镜像的大小 |
# 可选项
-a, --all # 列出所有镜像
-q, --quiet # 只显示镜像的id
[root@VM-0-13-centos /]# docker search python
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
python Python is an interpreted, interactive, objec… 5893 [OK]
# 可选项
--filter=STARS=3000 # 搜索出来的镜像就是STARS大于3000的
[root@VM-0-13-centos /]# docker search python --filter=STARS=3000
NAME DESCRIPTION STARS OFFICIAL AUTOMATED
python Python is an interpreted, interactive, objec… 5893 [OK]
# 下载镜像 docker pull [镜像:tag]
docker pull mysql
# 等价于
docker.io/library/mysql:latest
[root@VM-0-13-centos /]# docker pull mysql
Using default tag: latest # 如果不写tag,默认就是latest
latest: Pulling from library/mysql
a076a628af6f: Already exists
f6c208f3f991: Pull complete # 分成下载,docker images的核心 联合文件系统
88a9455a9165: Pull complete
406c9b8427c6: Pull complete
7c88599c0b25: Pull complete
25b5c6debdaf: Pull complete
43a5816f1617: Pull complete
1a8c919e89bf: Pull complete
9f3cf4bd1a07: Pull complete
80539cea118d: Pull complete
201b3cad54ce: Pull complete
944ba37e1c06: Pull complete
Digest: sha256:feada149cb8ff54eade1336da7c1d080c4a1c7ed82b5e320efb5beebed85ae8c
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest # 真实地址
# 指定版本下载
[root@VM-0-13-centos /]# docker pull mysql:5.7
5.7: Pulling from library/mysql
a076a628af6f: Already exists
f6c208f3f991: Already exists
88a9455a9165: Already exists
406c9b8427c6: Already exists
7c88599c0b25: Already exists
25b5c6debdaf: Already exists
43a5816f1617: Already exists
1831ac1245f4: Pull complete
37677b8c1f79: Pull complete
27e4ac3b0f6e: Pull complete
7227baa8c445: Pull complete
Digest: sha256:b3d1eff023f698cd433695c9506171f0d08a8f92a0c8063c1a4d9db9a55808df
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7
# 删除指定的容器
docker rmi -f 镜像id
# 删除多个容器
docker rmi -f 镜像id 镜像id
# 删除全部的容器
docker rmi -f $(docker images -aq)
我们有了镜像才可以创建容器
docker pull centos
docker run [可选参数] image
# 参数
--name=‘NAME‘ # 容器名字 用来区分容器
-d # 后台方式运行 nohup
-it # 使用交互的方式运行 进入容器查看内容
-p # 指定容器的端口
-p ip:主机端口:容器端口
-p 主机端口:容器端口
-p 容器端口
容器端口
-P # 随机指定端口
# 启动并进入容器
[root@VM-0-13-centos /]# docker run -it centos /bin/bash
[root@0098aafe4aea /]# ls
bin etc lib lost+found mnt proc run srv tmp var
dev home lib64 media opt root sbin sys usr
# 从容器中退到主机
[root@0098aafe4aea /]# exit
exit
[root@VM-0-13-centos /]# ls
bin data etc lib lost+found mnt proc run srv tmp var
boot dev home lib64 media opt root sbin sys usr
docker ps
[root@VM-0-13-centos /]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
65120b757c32 sentry "/entrypoint.sh run …" 24 hours ago Up 24 hours 9000/tcp sentry-worker-1
aea0d322c056 sentry "/entrypoint.sh run …" 24 hours ago Up 24 hours 9000/tcp sentry-cron
b82b272011a7 sentry "/entrypoint.sh run …" 24 hours ago Up 24 hours 0.0.0.0:9001->9000/tcp my-sentry
3042d4d03722 postgres "docker-entrypoint.s…" 25 hours ago Up 25 hours 5432/tcp sentry-postgres
b0db884b48a9 redis "docker-entrypoint.s…" 25 hours ago Up 25 hours 6379/tcp sentry-redis
-a # 列出当前正在运行的+历史运行过的容器
-n=? # 显示最近创建的容器
-q # 只显示容器的编号
exit # 直接停止并退出
CTRL + p + q # 容器不停止退出
# 删除指定的容器,不能删除正在运行的容器,如果要强制删除 rm -f
docker rm 容器id
# 删除所有的容器
docker rm -f $(docker ps -aq)
docker ps -a -q|xargs docker rm
# 启动容器
docker start 容器id
# 重启容器
docker restart 容器id
# 停止当前正在运行的容器
docker stop 容器id
# 强制停止当前容器
docker kill 容器id
标签:rgs hup work get sql arc 显示 proc target
原文地址:https://www.cnblogs.com/YiwenGG/p/14453154.html