ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

Docker常用基础命令详解

2021-05-13 09:51:49  阅读:214  来源: 互联网

标签:ago 常用 0.0 months 详解 docker Docker latest


Docker常用基础命令详解

欢迎关注博主公众号「Java大师」, 专注于分享Java领域干货文章, 关注回复「资源」, 免费领取全网最热的Java架构师学习PDF, 转载请注明出处 http://www.javaman.cn/docker/docker-basic-command

发布时间: 2021-4-22 9:11:33 作者: java大师

1、docker version 查看当前docker ce版本

[root@iZbp14ak3swm571msqxpohZ ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.0
 API version:       1.40
 Go version:        go1.13.15
 Git commit:        7287ab3
 Built:             Tue Dec  8 18:57:35 2020
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          19.03.14
  API version:      1.40 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       5eb3275d40
  Built:            Tue Dec  1 19:19:17 2020
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.2.6
  GitCommit:        894b81a4b802e4eb2a91d1ce216b8817763c29fb
 runc:
  Version:          1.0.0-rc8
  GitCommit:        425e105d5a03fabd737a126ad93d62a9eeede87f
 docker-init:
  Version:          0.18.0
  GitCommit:        fec3683
[root@iZbp14ak3swm571msqxpohZ ~]# 

2、docker images 查看系统镜像

[root@iZbp14ak3swm571msqxpohZ ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
redis        latest    6060df96cef3   3 months ago   104MB
nginx        latest    f6d0b4767a6c   4 months ago   133MB
mysql        5.7       697daaecf703   5 months ago   448MB
centos       latest    300e315adb2f   5 months ago   209MB
java         8         d23bdf5b1b1b   4 years ago    643MB

3、查看正在运行的容器

[root@iZbp14ak3swm571msqxpohZ ~]# docker ps
CONTAINER ID   IMAGE       COMMAND                  CREATED        STATUS        PORTS                                      NAMES
88d61b3ad7b9   nginx       "/docker-entrypoint.…"   7 weeks ago    Up 2 weeks    0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   my-nginx
11b5dbd336c8   mysql:5.7   "docker-entrypoint.s…"   3 months ago   Up 3 months   0.0.0.0:3306->3306/tcp, 33060/tcp          mysql

4、docker pull 获取镜像

[root@iZbp14ak3swm571msqxpohZ ~]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest

5、docker run 镜像名称,启动该镜像

[root@iZbp14ak3swm571msqxpohZ ~]# docker run hello-world 

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

6、docker rm 删除容器

[root@iZbp14ak3swm571msqxpohZ ~]# docker ps -a
CONTAINER ID   IMAGE         COMMAND                  CREATED          STATUS                      PORTS                                      NAMES
95fff9c6e1ab   hello-world   "/hello"                 46 seconds ago   Exited (0) 45 seconds ago                                              busy_heyrovsky
88d61b3ad7b9   nginx         "/docker-entrypoint.…"   7 weeks ago      Up 2 weeks                  0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   my-nginx
11b5dbd336c8   mysql:5.7     "docker-entrypoint.s…"   3 months ago     Up 3 months                 0.0.0.0:3306->3306/tcp, 33060/tcp          mysql
[root@iZbp14ak3swm571msqxpohZ ~]# docker rm 95fff9c6e1ab
95fff9c6e1ab
[root@iZbp14ak3swm571msqxpohZ ~]# docker ps -a
CONTAINER ID   IMAGE       COMMAND                  CREATED        STATUS                    PORTS                                      NAMES
88d61b3ad7b9   nginx       "/docker-entrypoint.…"   7 weeks ago    Up 2 weeks                0.0.0.0:80->80/tcp, 0.0.0.0:443->443/tcp   my-nginx
11b5dbd336c8   mysql:5.7   "docker-entrypoint.s…"   3 months ago   Up 3 months               0.0.0.0:3306->3306/tcp, 33060/tcp          mysql

7、docker rmi 镜像id或者镜像名称,删除镜像

[root@iZbp14ak3swm571msqxpohZ ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED        SIZE
hello-world   latest    d1165f221234   2 months ago   13.3kB
redis         latest    6060df96cef3   3 months ago   104MB
nginx         latest    f6d0b4767a6c   4 months ago   133MB
mysql         5.7       697daaecf703   5 months ago   448MB
centos        latest    300e315adb2f   5 months ago   209MB
java          8         d23bdf5b1b1b   4 years ago    643MB
[root@iZbp14ak3swm571msqxpohZ ~]# docker rmi d1165f221234
Untagged: hello-world:latest
Untagged: hello-world@sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
Deleted: sha256:d1165f2212346b2bab48cb01c1e39ee8ad1be46b87873d9ca7a4e434980a7726
Deleted: sha256:f22b99068db93900abe17f7f5e09ec775c2826ecfe9db961fea68293744144bd
[root@iZbp14ak3swm571msqxpohZ ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
redis        latest    6060df96cef3   3 months ago   104MB
nginx        latest    f6d0b4767a6c   4 months ago   133MB
mysql        5.7       697daaecf703   5 months ago   448MB
centos       latest    300e315adb2f   5 months ago   209MB
java         8         d23bdf5b1b1b   4 years ago    643MB

标签:ago,常用,0.0,months,详解,docker,Docker,latest
来源: https://blog.51cto.com/u_14896618/2772848

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有