Unable to find image 'hello-world:latest' locally (无法在本地找到该镜像) latest: Pulling from library/hello-world (从远程仓库拉取) 2db29710123e: Pull complete (拉取成功) Digest: sha256:10d7d58d5ebd2a652f4d93fdd86da8f265f5318c6a73cc5b6a9798ff6d2b2e67 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/
通过 docker images 查看本地所有镜像
REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 7 months ago 13.3kB
docker version #版本信息 docker info #详细信息 docker 命令 --help # 帮助
镜像命令
docker images 查看本地所有镜像
REPOSITORY TAG IMAGE ID CREATED SIZE hello-world latest feb5d9fea6a5 7 months ago 13.3kB
REPOSITORY 仓库原
TAG 仓库标签
IMAGE ID 镜像id
CREATED 镜像的创建时间
SIZE 大小
可选项
-a 显示全部
-f 过滤
-q 仅显示id
docker search 搜索命令
[root@iZ8vbioqlrpr01woefafo2Z ~]# docker search mysql NAME DESCRIPTION STARS OFFICIAL AUTOMATED mysql MySQL is a widely used, open-source relation… 12483 [OK] mariadb MariaDB Server is a high performing open sou… 4806 [OK] mysql/mysql-server Optimized MySQL Server Docker images. Create… 924 [OK] percona Percona Server is a fork of the MySQL relati… 575 [OK] phpmyadmin phpMyAdmin - A web interface for MySQL and M… 516 [OK] # ......
REPOSITORY TAG IMAGE ID CREATED SIZE mysql 5.7 c20987f18b13 4 months ago 448MB mysql latest 3218b38490ce 4 months ago 516MB hello-world latest feb5d9fea6a5 7 months ago 13.3kB [root@iZ8vbioqlrpr01woefafo2Z ~]# [root@iZ8vbioqlrpr01woefafo2Z ~]# docker rmi -f c20987f18b13 Untagged: mysql:5.7 Untagged: mysql@sha256:f2ad209efe9c67104167fc609cca6973c8422939491c9345270175a300419f94 Deleted: sha256:c20987f18b130f9d144c9828df630417e2a9523148930dc3963e9d0dab302a76 Deleted: sha256:6567396b065ee734fb2dbb80c8923324a778426dfd01969f091f1ab2d52c7989 Deleted: sha256:0910f12649d514b471f1583a16f672ab67e3d29d9833a15dc2df50dd5536e40f Deleted: sha256:6682af2fb40555c448b84711c7302d0f86fc716bbe9c7dc7dbd739ef9d757150 Deleted: sha256:5c062c3ac20f576d24454e74781511a5f96739f289edaadf2de934d06e910b92 [root@iZ8vbioqlrpr01woefafo2Z ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE mysql latest 3218b38490ce 4 months ago 516MB hello-world latest feb5d9fea6a5 7 months ago 13.3kB
docker rmi -f $(docker images -aq) 删除全部容器
安装一个centos镜像学习
docker pull centos Using default tag: latest latest: Pulling from library/centos a1d0c7532777: Pull complete Digest: sha256:a27fd8080b517143cbbbab9dfb7c8571c40d67d534bbdee55bd6c473f432b177 Status: Downloaded newer image for centos:latest docker.io/library/centos:latest
docker run [可选参数] image
参数说明
–name=”name” 给容器起名字
-d 后台方式运行
-it 使用交互方式运行,进入容器查看内容
-P 指定容器的端口(大写)
-p 主机端口:容器端口 映射
-p 容器端口
-p 随机端口(小写)
docker run -it centos /bin/bash 启动容器并用bash交互,可见内部也还是一个独立的centos系统
[root@iZ8vbioqlrpr01woefafo2Z ~]# docker run -it centos /bin/bash [root@4a4d1f89c446 /]# ls bin etc lib lost+found mnt proc run srv tmp var dev home lib64 media opt root sbin sys usr [root@4a4d1f89c446 /]#