Docker image operation

Source: Internet
Author: User
Tags ssh access docker ps docker hub docker run gluster

List Images

List all local Docker image

# docker Imagesrepository          TAG                 IMAGE ID            CREATED             VIRTUAL sizecentos              centos6             25c5298b1a36        2 weeks ago         215.8 MB

As you can see, repository is the image source Library, here is the CentOS

Tag: Each image has its own tag, here is CENTOS6

When using this image to launch the Docker container, the name is: CENTOS:CENTOS6

Image ID: Each image has its own independent ID

Download the new image


Find a new image

Many Docker users create their own image, and some of the image is uploaded to the Docker hub, and we can find the right image directly in the Docker hub.

You can also use the docker search command to find an image

# Docker Search CentOS |   Morename DESCRIPTION STARS Official                   Automatedcentos the official build of CentOS.   685 [OK] Tianon/centos CentOS 5 and 6, created using rinse instea ...                   Ansible/centos7-ansible ansible on Centos7 22                    [Ok]ariya/centos6-teamcity-server teamcity Server 8.1 on CentOS 6 8 [Ok]tutum/centos CentOS image with SSH access.   For the root ...   8 [Ok]berngp/docker-zabbix Runs Zabbix Server and Zabbix Web UI on a ...                                                                        8 [Ok]saltstack/centos-6-minimal              8      [Ok]blalor/centos bare-bones Base CentOS 6.5 Image 7                    [Ok]centos/freeipa Freeipa in Docker on CentOS 7   Steeef/graphite-centos CentOS 6.x with graphite and Carbon via ng ...                                                                           6 [Ok]dockerfiles/centos-lamp          6 [Ok]gluster/gluster GlusterFS 3.5-centos 6.5 Docker Repo                    6 [ok]ariya/centos6-teamcity-agent Build agent for Teamcity 8.1 5 [ok]tutum/centos-6.4 DEPRECATED. Use tutum/centos:6.4 instead.   ...   5 [ok]jdeathe/centos-ssh-apache-php CentOS-6 6.5 x86_64/apache/php/php m ... 5 [Ok]cern/centoS-wlcg-wn Centosos 6 image with pre-installed Softwa ...                     4

Create a new image
To update an existing image

Interactive mode start CENTOS:CENTOS6, install MySQL

# docker Run-t-i centos:centos6/bin/bashbash-4.1# bash-4.1# yum install-y MySQL Mysql-serve

When you are finished, exit exit interactive mode

# docker Ps-acontainer ID        IMAGE               COMMAND             CREATED             STATUS                         PORTS               names2e9de4d9c350        CentOS : Centos6      /bin/bash           2 minutes ago       Exited (0) 7 seconds ago                           Mad_colden   

You can see the container ID just turned off.

# docker commit-m= "install MySQL"-a= "hongtu Zang" 2e9de4d9c350 CENTOS6: hongtu5f3bca7952cac8900e08b5fac11cdd1a4941803edbb5442593a171fe574ed961

-M message, describing information

-A author,image Creator

# docker Imagesrepository          TAG                 IMAGE ID            CREATED              VIRTUAL SIZEcentos6             hongtu              5F3BCA7952CA About        a minute ago   320.3 mbcentos              centos6             25c5298b1a36        2 weeks ago          215.8 MB

Can see, more out of a tag for hongtu image, is we just created a good

Create an image from Dockerfile

Create a Dockerfile

# mkdir hongtu# CD hongtu/# Touch Dockerfile

Edit Dockerfile Content:

# This is a commentfrom centos:centos6maintainer hongtu Zang <[email protected]>run yum install-y MySQL Mysql-serve R

From base image

Maintainer author

Run the command to execute, here is the installation Mysql-server

docker runCreate a new template

# docker build-t= "Hongtu/centos6:v2".  Sending build context to Docker daemon 2.56 kbsending build context to Docker daemon Step 0:from CENTOS:CENTOS6--->  25c5298b1a36step 1:maintainer hongtu Zang <[email protected]>---> Using cache---> 52f35fcefd08step 2 : RUN yum install-y mysql mysql-server---> Running in 35ab46137fe7loaded plugins:fastestmirrorsetting up install Pr Ocessresolving dependencies--> Running Transaction Check---> Package mysql.x86_64 0:5.1.73-3.el6_5 would be installed--> processing dependency:mysql-libs = 5.1.73-3.el6_5 for package:mysql-5.1.73-3.el6_5.x86_64--> Processing Dependency:perl (sys::hostname) for package:mysql-5.1.73-3.el6_5.x86_64--> Processing Dependency:perl ( IPC::OPEN3) for package:mysql-5.1.73-3.el6_5.x86_64--> processing Dependency:perl (Getopt::Long) for the package: mysql-5.1.73-3.el6_5.x86_64--> processing Dependency:perl (file::temp) for package:mysql-5.1.73-3.el6_5.x86_64-- > Processing DepeNdency:perl (FCNTL) for package:mysql-5.1.73-3.el6_5.x86_64--> processing Dependency:perl (Exporter) for the package: mysql-5.1.73-3.el6_5.x86_64--> processing dependency:libmysqlclient_r.so.16 (libmysqlclient_16) (64bit) for package:mysql-5.1.73-3.el6_5.x86_64--> processing dependency:libmysqlclient.so.16 (libmysqlclient_16) (64bit) For package:mysql-5.1.73-3.el6_5.x86_64--> processing Dependency:/usr/bin/perl for Package:mysql-5.1.73-3.el6_5. X86_64--> processing dependency:libmysqlclient_r.so.16 () (64bit) for package:mysql-5.1.73-3.el6_5.x86_64--> Processing dependency:libmysqlclient.so.16 () (64bit) for package:mysql-5.1.73-3.el6_5.x86_64---> Package Mysql-server.x86_64 0:5.1.73-3.el6_5 'll be installed--> processing dependency:perl-dbi for package:mysql-server-5 .1.73-3.el6_5.x86_64--> processing dependency:perl-dbd-mysql for package:mysql-server-5.1.73-3.el6_5.x86_64-- > Processing Dependency:perl (DBI) for package:mysql-server-5.1.73-3.el6_5.x86_64--> Running Transaction Check---> Package mysql-libs.x86_64 0:5.1.73-3.el6_5 would be installed---> package per L.x86_64 4:5.10.1-136.el6_6.1 'll be installed--> processing dependency:perl-libs = 4:5.10.1-136.el6_6.1 for Package : 4:perl-5.10.1-136.el6_6.1.x86_64--> processing dependency:perl-libs for package:4:perl-5.10.1-136.el6_6.1.x86_ 64--> processing Dependency:perl (version) for package:4:perl-5.10.1-136.el6_6.1.x86_64--> Processing Dependency:perl (pod::simple) for package:4:perl-5.10.1-136.el6_6.1.x86_64--> processing Dependency:perl (Module: :P luggable) for package:4:perl-5.10.1-136.el6_6.1.x86_64--> processing Dependency:libperl.so () (64bit) : 4:perl-5.10.1-136.el6_6.1.x86_64---> Package perl-dbd-mysql.x86_64 0:4.013-3.el6 'll be a installed---> package Perl-dbi.x86_64 0:1.609-4.el6 'll be installed--> Running transaction Check---> Package Perl-module-pluggable.x86_64 1:3.90-136.el6_6.1 'll be installed---> Package peRl-pod-simple.x86_64 1:3.13-136.el6_6.1 'll be installed--> processing Dependency:perl (Pod::Escapes) >= 1.04 for PACKAGE:1:PERL-POD-SIMPLE-3.13-136.EL6_6.1.X86_64---> Package perl-libs.x86_64 4:5.10.1-136.el6_6.1 'll be Installed---> Package perl-version.x86_64 3:0.77-136.el6_6.1 'll be installed--> Running transaction Check--- > Package perl-pod-escapes.x86_64 1:1.04-136.el6_6.1 'll be installed--> finished Dependency Resolutiondependencies resolved================================================================================ Package Arch Version Repository size============================================ ====================================installing:mysql x86_64 5.1.73-3.el6_5 Base 8                94 k mysql-server x86_64 5.1.73-3.el6_5 base 8.6 minstalling for Dependencies:mysql-libs x86_64 5.1.73-3.el6_5 Base 1.2 M perl                     x86_64 4:5.10.1-136.el6_6.1 updates ten M perl-dbd-mysql x86_64 4.013-3.el6 Base 134 k perl-dbi x86_64 1.609-4.el6 base 705 k Perl-module         -pluggable x86_64 1:3.90-136.el6_6.1 updates k perl-pod-escapes x86_64 1:1.04-136.el6_6.1                Updates from K perl-pod-simple x86_64 1:3.13-136.el6_6.1 updates 212 k perl-libs         x86_64 4:5.10.1-136.el6_6.1 updates 578 k perl-version x86_64 3:0.77-136.el6_6.1 Updates Wuyi ktransaction summary================================================================================ Install one package (s) total download size:23 minstalled size:69 mdownloading Packages:------------------------------  --------------------------------------------------Total 104 kb/s | 03:42 MB Warning:rpmts_hdrfromFdno:header V3 rsa/sha1 Signature, key ID c105b9de:nokeyretrieving key from file:///etc/pki/rpm-gpg/rpm-gpg-key-centos- 6Importing GPG key 0xc105b9de:userid:centos-6 Key (CentOS 6 official Signing key) <[email protected]> Packag E:centos-release-6-6.el6.centos.12.2.x86_64 (@CentOS/$releasever) from:/etc/pki/rpm-gpg/ Rpm-gpg-key-centos-6running rpm_check_debugrunning Transaction testtransaction Test succeededrunning  Transactionwarning:rpmdb altered outside of Yum. installing:mysql-libs-5.1.73-3.el6_5.x86_64 1/11 INSTALLING:1:PERL-POD-ESCAPES-1.04-136.E l6_6.1.x86_64 2/11 installing:4:perl-libs-5.10.1-136.el6_6.1.x86_64 3/11 Inst Alling:1:perl-module-pluggable-3.90-136.el6_6.1.x86_64 4/11 Installing:1:perl-pod-simple-3.13-136.el6_6. 1.x86_64 5/11 installing:3:perl-version-0.77-136.el6_6.1.x86_64 6/11 Installi Ng:4:perl-5.10.1-136.el6_6.1.x86_64 7/11 installing:perl-dbi-1.609-4.el6.x86_64 8 /11 installing:perl-dbd-mysql-4.013-3.el6.x86_64 9/11 installing:mysql-5.1.73-3.el6_5.x8   6_64 10/11 installing:mysql-server-5.1.73-3.el6_5.x86_64 11/11 Verifying:3:perl-version-0.77-136.el6_6.1.x86_64 1/11 verifying:perl-dbd-mysql-4.013-3.el6. x86_64 2/11 verifying:mysql-libs-5.1.73-3.el6_5.x86_64 3/11 Ve                                 rifying:mysql-server-5.1.73-3.el6_5.x86_64 4/11 verifying:mysql-5.1.73-3.el6_5.x86_64 5/11 verifying:perl-dbi-1.609-4.el6.x86_64 6/11 Verify                           ing:1:perl-pod-simple-3.13-136.el6_6.1.x86_64 7/11 verifying:4:perl-5.10.1-136.el6_6.1.x86_64 8/11 verifying:4:perl-libs-5.10.1-136.el6_6.1.x86_64 9/11 Verifying:1:perl-module-pluggab le-3.90-136.el6_6.1.x86_64 10/11 verifying:1:perl-pod-escapes-1.04-136.el6_6.1.x86_64 11/1 1 Installed:mysql.x86_64 0:5.1.73-3.el6_5 mysql-server.x86_64 0:5.1.73-3.el6_5 Dependency installed:mysql-l                                                ibs.x86_64 0:5.1.73-3.el6_5 perl.x86_64 4:5.10.1-136.el6_6.1 perl-dbd-mysql.x86_64 0:4.013-3.el6 perl-dbi.x8                                 6_64 0:1.609-4.el6 perl-module-pluggable.x86_64 1:3.90-136.el6_6.1 perl-pod-escapes.x86_64 1:1.04-136.el6_6.1 Perl-pod-simple                                           . x86_64 1:3.13-136.el6_6.1 perl-libs.x86_64 4:5.10.1-136.el6_6.1 Perl-version.x86_64 3:0.77-136.el6_6.1 complete! ---> 4ee0c1aacb0eremoving intermediate container 35ab46137fe7successfully built 4ee0c1aacb0

Create a new image successfully

-tDefines the Image property, which belongs to the user, and hongtu repository is centos tag specified as v2

.Specifies that the current directory is looking forDockerfile

# docker Imagesrepository          TAG                 IMAGE ID            CREATED             VIRTUAL sizehongtu/centos6      v2                  4ee0c1aacb0e        2 minutes ago       323.1 MBcentos6             hongtu              5f3bca7952ca to        minutes ago      320.3 Mbcentos              centos6             25c5298b1a36        2 weeks ago         215.8 MB

You can see that the newly created image ID is 4ee0c1aacb0e

Uploading an image to the Docker hub

# Docker Push HONGTU/CENTOS6

Delete local image

# docker Rmi-f HONGTU/CENTOS6

-fForce Delete



Docker image operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.