美文网首页Docker应用
mac Docker基本操作命令

mac Docker基本操作命令

作者: Geroge1226 | 来源:发表于2021-05-14 14:14 被阅读0次

docker中央仓库: index.docker.io 可以自己搭建私域仓库。

1、docker Images 查看docker 本地镜像

[lsy@lsyPro /etc ]$ docker images
REPOSITORY   TAG       IMAGE ID       CREATED      SIZE
rabbitmq     latest    32497bcd639d   3 days ago   156MB

REPOSITORY: 仓库中镜像名称
TAG: 镜像的标签信息,比如 5.7、latest 表示不同的版本信息;
IMAGE ID:镜像的 ID, 如果您看到两个 ID 完全相同,那么实际上,它们指向的是同一个镜像,只是标签名称不同罢了;
CREATED:镜像最后的更新时间;
SIZE: 镜像的大小,优秀的镜像一般体积都比较小,这也是我更倾向于使用轻量级的 alpine 版本的原因;

2、docker pull 拉取镜像

[lxx@lsyPro /etc ]$ docker pull nginx
Using default tag: latest
latest: Pulling from library/nginx
69692152171a: Pull complete 
49f7d34d62c1: Pull complete 
5f97dc5d71ab: Pull complete 
cfcd0711b93a: Pull complete 
be6172d7651b: Pull complete 
de9813870342: Pull complete 
Digest: sha256:df13abe416e37eb3db4722840dd479b00ba193ac6606e7902331dcea50f4f1f2
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest

说明
1、pull的镜像名称均为小写,可以在中央仓库中搜索到
2、 指定版本号

3、docker ps 查看docker中运行的容器

[lxxd@lsyPro /etc ]$ docker ps 
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                                                                                              NAMES
b1926a54a2e3   rabbitmq   "docker-entrypoint.s…"   25 seconds ago   Up 23 seconds   4369/tcp, 0.0.0.0:5672->5672/tcp, 5671/tcp, 15691-15692/tcp, 25672/tcp, 0.0.0.0:15672->15672/tcp   rbmq

4、docker run 启动容器

[lng@lsyPro /etc ]$ docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:5122f6204b6a3596e048758cabba3c46b1c937a46b5be6225b835d091b90e46c
Status: Downloaded newer image for hello-world:latest
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/

4.1 说明:

  • docker run先会去本地镜像仓库查找运行的镜像,找不到,则回去远程仓库拉取镜像,拉取完毕在运行镜像。

4.2 参数说明

参数 全称 说明
-d --detached==false 指定容器运行于前台还是后台,默认为false( in background)
-h --hostname="" 指定容器的主机名
--name --name="" 指定容器名字,后续可以通过名字进行容器管理,links特性需要使用名字
-p --publish=[] (小写p)指定容器暴露的端口

【例子】

docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 rabbitmq

相关文章

  • docker 基本命令

    一,关于docker镜像操作的基本命令 二,关于docker容器操作的基本命令 三,关于docker仓库操作的基本命令

  • mac Docker基本操作命令

    docker中央仓库: index.docker.io[http://index.docker.io/] 可以自己...

  • Docker学习笔记

    基本操作 docker for mac https://docs.docker.com/docker-for-ma...

  • Docker 部署前端项目流程

    1、基本的 docker 操作命令 docker images --- 查看所以镜像 docker search ...

  • docker常用命令总结

    参考链接 Docker 常用命令与操作 docker常用命令总结——安装、镜像、容器基本操作

  • docker基本操作命令

    常用命令 查看容器的root用户密码 查看容器日志docker logs -f <容器名orID> 查看正在运行的...

  • docker基本操作命令

    我的博客:https://blog.thuol.com 这几个操作命令是我最近用到的。具体参数可以查看官方文档。 ...

  • Docker基本操作命令

    Docker关于image的相关命令 查看本地image信息docker imagesdocker image l...

  • 【2】docker 基本操作.md

    【2】docker 基本操作 基本命令 示例 容器操作 绑定服务到TCP端口 提交(保存)容器状态

  • 记录一次Docker的学习

    Docker学习 Docker概述 Docker安装 Docker命令镜像命令容器命令操作命令... Docker...

网友评论

    本文标题:mac Docker基本操作命令

    本文链接:https://www.haomeiwen.com/subject/scjurltx.html