docker导出日志到本地的方法是什么
249
2022-10-20
Docker----Docker镜像操作常用命令
一、帮助命令
docker version # 查看docker 版本信息docker info # 查看docker 系统信息docker 命令 --help # 查看docker 常用命令的使用方法
二、镜像命令
2.1 docker images 命令
(1)docker images 查看主机上的镜像
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
(2)docker images --help 查看 docker images的帮助信息
[root@localhost ~]# docker images --helpUsage: docker images [OPTIONS] [REPOSITORY[:TAG]]List imagesOptions: -a, --all Show all images (default hides intermediate images) --digests Show digests -f, --filter filter Filter output based on conditions provided --format string Pretty-print images using a Go template --no-trunc Don't truncate output -q, --quiet Only show image IDs[root@localhost ~]#
(3)docker images -a 查看主机上的所有镜像
[root@localhost ~]# docker images -aREPOSITORY TAG IMAGE ID CREATED SIZEhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
(4)docker images -q 只显示docker镜像的id
[root@localhost ~]# docker images -qfeb5d9fea6a5[root@localhost ~]#
2.2 docker search 镜像名称 命令
(1)docker search 镜像名称,搜索镜像
[root@localhost ~]# docker search mysqlNAME DESCRIPTION STARS OFFICIAL AUTOMATEDmysql MySQL is a widely used, open-source relation… 11516 [OK]mariadb MariaDB Server is a high performing open sou… 4369 [OK]mysql/mysql-server Optimized MySQL Server Docker images. Create… 851 [OK]percona Percona Server is a fork of the MySQL relati… 558 [OK]phpmyadmin phpMyAdmin - A web interface for MySQL and M… 339 [OK]centos/mysql-57-centos7 MySQL 5.7 SQL database server 91mysql/mysql-cluster Experimental MySQL Cluster Docker images. Cr… 88centurylink/mysql Image containing mysql. Optimized to be link… 59 [OK]databack/mysql-backup Back up mysql databases to... anywhere! 51prom/mysqld-exporter 42 [OK]deitch/mysql-backup REPLACED! Please use 41 [OK]tutum/mysql Base docker image to run a MySQL database se… 35linuxserver/mysql A Mysql container, brought to you by LinuxSe… 31schickling/mysql-backup-s3 Backup MySQL to S3 (supports periodic backup… 31 [OK]mysql/mysql-router MySQL Router provides transparent routing be… 23centos/mysql-56-centos7 MySQL 5.6 SQL database server 20arey/mysql-client Run a MySQL client from a docker container 18 [OK]fradelg/mysql-cron-backup MySQL/MariaDB database backup using cron tas… 16 [OK]openshift/mysql-55-centos7 DEPRECATED: A Centos7 based MySQL v5.5 image… 6idoall/mysql MySQL is a widely used, open-source relation… 3 [OK]devilbox/mysql Retagged MySQL, MariaDB and PerconaDB offici… 3jelastic/mysql An image of the MySQL database server mainta… 2ansibleplaybookbundle/mysql-apb An APB which deploys RHSCL MySQL 2 [OK]widdpim/mysql-client Dockerized MySQL Client (5.7) including Curl… 1 [OK]centos/mysql-80-centos7 MySQL 8.0 SQL database server 1[root@localhost ~]#
(2)docker search --help 查看docker search 命令的帮助信息
[root@localhost ~]# docker search --helpUsage: docker search [OPTIONS] TERMSearch the Docker Hub for imagesOptions: -f, --filter filter Filter output based on conditions provided --format string Pretty-print search using a Go template --limit int Max number of search results (default 25) --no-trunc Don't truncate output[root@localhost ~]#
(3)docker search --filter 过滤条件 根据过滤条件搜索镜像 如下为搜索收藏数大于等于3000的mysql镜像
[root@localhost ~]# docker search mysql --filter stars=3000NAME DESCRIPTION STARS OFFICIAL AUTOMATEDmysql MySQL is a widely used, open-source relation… 11516 [OK]mariadb MariaDB Server is a high performing open sou… 4369 [OK][root@localhost ~]#
2.3 docker pull 命令
(1) docker pull 镜像名称 下载最新版的镜像 如下为下载最新版的mysql镜像
[root@localhost ~]# docker pull mysqlUsing default tag: latestlatest: Pulling from library/mysql07aded7c29c6: Pull completef68b8cbd22de: Pull complete30c1754a28c4: Pull complete1b7cb4d6fe05: Pull complete79a41dc56b9a: Pull complete00a75e3842fb: Pull completeb36a6919c217: Pull complete635b0b84d686: Pull complete6d24c7242d02: Pull complete5be6c5edf16f: Pull completecb35eac1242c: Pull completea573d4e1c407: Pull completeDigest: sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213dStatus: Downloaded newer image for mysql:latestdocker.io/library/mysql:latest[root@localhost ~]#
如下,可以看到显示已经下载完成的mysql镜像版本为latest
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
(2)docker pull 镜像名称:tag 下载指定版本的镜像 如下为指定下载5.7版本的mysql
[root@localhost ~]# docker pull mysql:5.75.7: Pulling from library/mysql07aded7c29c6: Already existsf68b8cbd22de: Already exists30c1754a28c4: Already exists1b7cb4d6fe05: Already exists79a41dc56b9a: Already exists00a75e3842fb: Already existsb36a6919c217: Already exists5e11fe494f45: Pull complete9c7de1f889a7: Pull completecf6a13d05a76: Pull completefc5aa81f393a: Pull completeDigest: sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189Status: Downloaded newer image for mysql:5.7docker.io/library/mysql:5.7[root@localhost ~]#
如下,可以看到本地已经存在5.7版本的mysql镜像
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7 9f35042c6a98 11 days ago 448MBmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
2.4 docker rmi 删除镜像
(1)docker rmi 镜像id 根据镜像id删除镜像 如下为根据镜像id删除5.7版的mysql镜像的操作
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7 9f35042c6a98 11 days ago 448MBmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]# docker rmi 9f35042c6a98Untagged: mysql:5.7Untagged: mysql@sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189Deleted: sha256:9f35042c6a98363147ae456147643a3d14c484640f13f4ab207cf2c296839bafDeleted: sha256:69a5732b5b989ff688326db6354b0f50165a71cfe7579b285054b561fb3c5143Deleted: sha256:448b1f9cb8f126363f0e809e0e450c493ca1e725715127a258c5346fcae7cd8aDeleted: sha256:4064542818b4bf92f293da870d3ea1413a20d0c1a83f72917c50986880255338Deleted: sha256:8ca7f5e08bac7aa39cf9b8b79bf40669373b9aed45ec76eb0fa55109350b6672[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
(2)docker rmi -f 镜像id 根据镜像id强制删除镜像 一般常用加 -f 的方式删除
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7 9f35042c6a98 11 days ago 448MBmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]# docker rmi -f 2fe463762680Untagged: mysql:latestUntagged: mysql@sha256:4fcf5df6c46c80db19675a5c067e737c1bc8b0e78e94e816a778ae2c6577213dDeleted: sha256:2fe4637626805dc6df98d3dc17fa9b5035802dcbd3832ead172e3145cd7c07c2Deleted: sha256:e00bdaa10222919253848d65585d53278a2f494ce8c6a445e5af0ebfe239b3b5Deleted: sha256:83411745a5928b2a3c2b6510363218fb390329f824e04bab13573e7a752afd50Deleted: sha256:e8e521a71a92aad623b250b0a192a22d54ad8bbeb943f7111026041dce20d94fDeleted: sha256:024ee0ef78b28663bc07df401ae3a258ae012bd5f37c2960cf638ab4bc04fafdDeleted: sha256:597139ec344c8cb622127618ae21345b96dd23e36b5d04b071a3fd92d207a2c0[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7 9f35042c6a98 11 days ago 448MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]#
(3)docker rmi -f $(docker images -aq) 删除所有镜像
[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEmysql 5.7 9f35042c6a98 11 days ago 448MBmysql latest 2fe463762680 11 days ago 514MBhello-world latest feb5d9fea6a5 2 weeks ago 13.3kB[root@localhost ~]# docker rmi -f $(docker images -aq)Untagged: mysql:5.7Untagged: mysql@sha256:360c7488c2b5d112804a74cd272d1070d264eef4812d9a9cc6b8ed68c3546189Deleted: sha256:9f35042c6a98363147ae456147643a3d14c484640f13f4ab207cf2c296839bafDeleted: sha256:69a5732b5b989ff688326db6354b0f50165a71cfe7579b285054b561fb3c5143Deleted: sha256:448b1f9cb8f126363f0e809e0e450c493ca1e725715127a258c5346fcae7cd8aDeleted: sha256:4064542818b4bf92f293da870d3ea1413a20d0c1a83f72917c50986880255338[root@localhost ~]# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZE[root@localhost ~]#
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~