docker study notes 2-- common operations

  1 ), the mirror operation

 

operating command Explanation
Retrieval docker search keywords eg: docker search redis We often detailed information on the hub to retrieve the mirror docker, such as mirroring of TAG.
Pull docker pull mirror name: tag : Tag is optional, tag represents the label, multi-version software, the default is the latest
List docker images View all local mirror
delete docker rmi image-id Delete the specified local mirror

  The official website can be used https://hub.docker.com/, the country can use Ali cloud, or Netease cloud.

    1. Search Mirror 

[root@localhost ~]# docker search mysql

    

    2, pulling the mirror

[root@localhost ~]# docker pull mysql

   

  Pulling specified version mirror

[root@localhost ~]# docker pull mysql:5.5

  

  3. Check all local mirror

[root@localhost ~]# docker images

  

  4, remove the mirror, the mirror according to delete id

 

Delete commands, [root @ localhost ~] # docker rmi d404d78aa797, according to docker images check out the IMAGE ID to remove the mirror.

 

 

 

  2 ), container operations (operating too lazy to make the list, Silicon Valley is still attached to a docker action list instructions)

    

 

 

 

 

   1, start the container according to the image

[root@localhost ~]# docker run --name mytomcat -d tomcat:latest

  Note: - name parameter back to run container custom name (also can not specify a custom name), - d represents the background (behind the mirror parameter name), a colon after the argument as a tag number, such as: latest represent the latest version (last updated version) it can be omitted, I am here to explain it more intuitive added, generally not the latest version tag number must be added to run the container.

  2. Check the running container

 

[root@localhost ~]# docker ps

 

 

   3, stop the operation of the vessel

[root@localhost ~]# docker stop adc48bc0a25a

 

 

   

[Root @ localhost ~] # docker ps -a # view all containers, including containers has exited, exit status indicates a container for the Exited

 

 

   It may also be used in accordance with the following command to restart the container CONTAINER ID

[root@localhost ~]# docker start adc48bc0a25a

  4, after the container has stopped unnecessary can be deleted by using the following operation order under CONTAINER ID:

[root@localhost ~]# docker rm  adc48bc0a25a

 

 

   Re-use docker ps -a to view all containers will find deleted tomcat container no longer exists

 

 

   5, the virtual machine container port to port mapping, for example to start a tomcat port mapping of tomcat

[root @ localhost ~] # Docker RUN -d -p 8888 : 8080 tomcat # -d represents the background, -p represents port mapping, which represents a virtual machine port 8888, 8080 represents a container port tomcat 
-d : background
-p : the host port is mapped to a port of the host port of the container : the interior of the container port (again)

 

   6, then you can add virtual machines to access tomcat port number through a virtual machine IP, if you can not access your own Baidu linux turn off the firewall or open ports execution.

 

 

 

    7, view the boot log container

[Root @ localhost ~] # docker logs 98c3fb8fd426 # view according CONTAINER ID
[root@localhost ~]# docker logs 98c3fb8fd426
14-Sep-2019 15:58:31.313 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server version:        Apache Tomcat/8.5.45
14-Sep-2019 15:58:31.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server built:          Aug 14 2019 22:21:25 UTC
14-Sep-2019 15:58:31.421 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Server number:         8.5.45.0
14-Sep-2019 15:58:31.428 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Name:               Linux
14-Sep-2019 15:58:31.428 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log OS Version:            3.10.0-957.el7.x86_64
14-Sep-2019 15:58:31.428 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Architecture:          amd64
14-Sep-2019 15:58:31.428 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Java Home:             /usr/local/openjdk-8/jre
14-Sep-2019 15:58:31.428 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Version:           1.8.0_222-b10
14-Sep-2019 15:58:31.429 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log JVM Vendor:            Oracle Corporation
14-Sep-2019 15:58:31.429 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_BASE:         /usr/local/tomcat
14-Sep-2019 15:58:31.429 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log CATALINA_HOME:         /usr/local/tomcat
14-Sep-2019 15:58:31.429 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djdk.tls.ephemeralDHKeySize=2048
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.protocol.handler.pkgs=org.apache.catalina.webresources
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dorg.apache.catalina.security.SecurityListener.UMASK=0027
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dignore.endorsed.dirs=
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.base=/usr/local/tomcat
14-Sep-2019 15:58:31.430 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Dcatalina.home=/usr/local/tomcat
14-Sep-2019 15:58:31.431 INFO [main] org.apache.catalina.startup.VersionLoggerListener.log Command line argument: -Djava.io.tmpdir=/usr/local/tomcat/temp
14-Sep-2019 15:58:31.431 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent Loaded APR based Apache Tomcat Native library [1.2.23] using APR version [1.5.2].
14-Sep-2019 15:58:31.431 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
14-Sep-2019 15:58:31.431 INFO [main] org.apache.catalina.core.AprLifecycleListener.lifecycleEvent APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
14-Sep-2019 15:58:31.442 INFO [main] org.apache.catalina.core.AprLifecycleListener.initializeSSL OpenSSL successfully initialized [OpenSSL 1.1.0k  28 May 2019]
14-Sep-2019 15:58:32.134 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["http-nio-8080"]
14-Sep-2019 15:58:32.164 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
14-Sep-2019 15:58:32.211 INFO [main] org.apache.coyote.AbstractProtocol.init Initializing ProtocolHandler ["ajp-nio-8009"]
14-Sep-2019 15:58:32.235 INFO [main] org.apache.tomcat.util.net.NioSelectorPool.getSharedSelector Using a shared selector for servlet write/read
14-Sep-2019 15:58:32.238 INFO [main] org.apache.catalina.startup.Catalina.load Initialization processed in 4413 ms
14-Sep-2019 15:58:32.426 INFO [main] org.apache.catalina.core.StandardService.startInternal Starting service [Catalina]
14-Sep-2019 15:58:32.427 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet Engine: Apache Tomcat/8.5.45
14-Sep-2019 15:58:32.486 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/ROOT]
14-Sep-2019 15:58:33.996 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/ROOT] has finished in [1,503] ms
14-Sep-2019 15:58:33.997 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/docs]
14-Sep-2019 15:58:34.115 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/docs] has finished in [119] ms
14-Sep-2019 15:58:34.115 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/examples]
14-Sep-2019 15:58:36.190 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/examples] has finished in [2,075] ms
14-Sep-2019 15:58:36.190 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/host-manager]
14-Sep-2019 15:58:36.289 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/host-manager] has finished in [99] ms
14-Sep-2019 15:58:36.289 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deploying web application directory [/usr/local/tomcat/webapps/manager]
14-Sep-2019 15:58:36.343 INFO [localhost-startStop-1] org.apache.catalina.startup.HostConfig.deployDirectory Deployment of web application directory [/usr/local/tomcat/webapps/manager] has finished in [54] ms
14-Sep-2019 15:58:36.357 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["http-nio-8080"]
14-Sep-2019 15:58:36.388 INFO [main] org.apache.coyote.AbstractProtocol.start Starting ProtocolHandler ["ajp-nio-8009"]
14-Sep-2019 15:58:36.396 INFO [main] org.apache.catalina.startup.Catalina.start Server startup in 4158 ms

    Thus, mirror operation Docker operation has concluded and the container is completed by illustrations, of course, many more operations involving more commands refer to reference each image https://docs.docker.com/engine/reference/commandline/docker/ document , here is not a demo, and I was a novice while learning side of the record, there is inadequate please the god of generosity.


 

Guess you like

Origin www.cnblogs.com/3wweblogs-a/p/11520877.html