docker基础操作

[root@bogon docker]# docker search mysql (查询docker 库)

INDEX       NAME                                                             DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED

docker.io   docker.io/mysql                                                  MySQL is a widely used, open-source relati...   6349      [OK]       

docker.io   docker.io/mariadb                                                MariaDB is a community-developed fork of M...   1993      [OK]       

docker.io   docker.io/mysql/mysql-server                                     Optimized MySQL Server Docker images. Crea...   456                  [OK]

docker.io   docker.io/percona                                                Percona Server is a fork of the MySQL rela...   343       [OK]       

docker.io   docker.io/zabbix/zabbix-server-mysql                             Zabbix Server with MySQL database support       101                  [OK]

docker.io   docker.io/hypriot/rpi-mysql                                      RPi-compatible Docker Image with Mysql          87                   

docker.io   docker.io/centurylink/mysql                                      Image containing mysql. Optimized to be li...   60                   [OK]

docker.io   docker.io/zabbix/zabbix-web-nginx-mysql                          Zabbix frontend based on Nginx web-server ...   52                   [OK]

docker.io   docker.io/1and1internet/ubuntu-16-nginx-php-phpmyadmin-mysql-5  

[root@bogon docker]# docker push (上传镜像)

 

[root@bogon docker]# docker images docker.io/ (查询拥有镜像)

 

[root@bogon docker]# docker ps (列出容器)

 

[root@bogon docker]# docker attach test01  (链接容器)

 

[root@6ddc8b83e1d6 home]# ls[root@bogon docker]# Ctrl+P+q挂起容器,后台运行)

 

[root@bogon docker]# docker exec test01 ls /home (运行容器当中的命令)

[root@bogon docker]# ls volumes/ (查看卷)

[root@bogon docker]# docker run -itd --name test01 centos (创建容器)

[root@bogon docker]# docker ps (容器查询)

[root@bogon docker]# docker images (查看创建的镜像)

 

[root@bogon docker]# docker rmi hello-world (删除镜像

docker rmi -f $(docker images)(强制删除所有镜像)

docker rm -f $(docker ps -q -a)(强制删除所有容器)

 

[root@bogon docker]#docker export test01 > test01.tar (将test01的容器导出)

 

 

docker import test01.tar NAME:ATG  \docker import test02 < test01.tar  (将test01.tar容器导入)

 

[root@bogon /]# docker save mysql > mysql.tar (docker pull mysql 的镜像导出)

 

[root@bogon /]# ls -h

 

bin   dev  home  lib64  mnt        opt   root  sbin  sys         tmp  var

 

boot  etc  lib   media  mysql.tar  proc  run   srv   test01.tar  usr

 

[root@bogon /]# ll -h

 

总用量 628M

 

-rw-r--r--.   1 root root 429M 6月  12 05:29 mysql.tar

 

[root@bogon /]# docker load -i mysql.tar (将打包的mysql.tar镜像导入)

 

Loaded image: docker.io/mysql:latest

 

[root@bogon /]# docker ps

 

CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

 

c3ffbcccb8c1        centos:self         "/bin/bash"         28 minutes ago      Up 28 minutes                           test01_self

 

dcc5e2773a56        centos              "/bin/bash"         42 minutes ago      Up 42 minutes                           test01

 

[root@bogon /]# docker images

 

 

posted @ 2018-06-22 10:07  听_风~  阅读(116)  评论(0编辑  收藏  举报