CentOS 7 x64 Docker preliminary interview

Source: Internet
Author: User
Tags docker ps

CentOS 7 x64 Docker use


CentOS 7 Installation Docker


Yum Search Docker to see if a Docker package is available

Yum Info Docker version is 1.3.2

Yum-y Install Docker installation Docker


Docker--version

Docker version 1.3.2, build 39fa2fa/1.3.2


Close Firewalld and Selinux


Service Docker start start


Systemctl Enable Docker Setup boot



Get the CentOS image


Docker pull Centos:latest Download the latest version of the image

Or

Docker pull centos:centos6 Download CENTOS6 image, etc.



To view the installation image


Docker images


REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

CentOS 7 8efe422e6104 2 weeks ago 224 MB

CentOS centos7 8efe422e6104 2 weeks ago 224 MB

CentOS latest 8efe422e6104 2 weeks ago 224 MB



Run Shell Bash under Docker


Docker run-i-T <image id>/bin/bash//<image id> obtained via Docker images command, here is 510cf09a7986


Docker Run-i-T 8efe422e6104/bin/bash


Docker run-i-T <image id>/bin/bash//A container that runs this way, the container shuts down automatically after exiting, this way is to create a new container.


Docker run-i-t-v/opt/software:/opt/software <image id>/bin/bash//-v for Mount Local directory, first/opt/software to local directory: container behind Directory, directory does not exist will be created automatically



After execution, switch to


[Email protected]/]#


Installing SSH passwd under the container


Yum-y Install Openssh-server passwd


Modify the root password after the installation is complete

passwd


Then install the JDK and tomcat!!


The installation process is the same as when the physical machine installation process is complete



Back to physical machine



Docker ps-a to view a running Docker shell


CONTAINER ID IMAGE COMMAND CREATED STATUS

c6291c68a800 centos:7 "/bin/bash" 3 hours ago Exited (0) 3 minutes ago




Docker commit <container id> <name>//Modify mirror image name


Docker commit c6291c68a800 Tomcat//Save the name of this image as Tomcat



Docker images


REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE

Tomcat-1 latest 983e0f7ea1fd Notoginseng minutes ago 779.8 MB


Docker Ps-a


CONTAINER ID IMAGE COMMAND CREATED STATUS

ED1EFC2C7D01 tomcat:latest "/bin/bash" 9 minutes ago Exited (0) 3 minutes ago



Docker start <container id>//<container id> get started with Docker ps-a command


Docker attach <container id>//return to this container


Docker start-i <container id>//boot this container and connect to this container



Start the container's SSH and map the port


Docker run-d-P 50001:22 <image id>/usr/sbin/sshd-d//<image id> for Docker images get the IMAGE ID you need to get Tomcat


Ssh-p 50001 127.0.0.1 into the container


Launch Tomcat view container IP


Back to physical machine


Curl-i Container ip:8080 See if it's OK



-------------------------------------------------------------------------------------------------------

Other Run commands


View Docker Run logs


Docker logs-f <container id>


Delete a container

Docker rm <container id>//<container id> via Docker ps-a command


Remove all containers

Docker RM $ (Docker ps-a-Q)


Delete an image

Docker rmi <image ID >//<image id> via Docker images command

--------------------------------------------------------------------------------------------------------


This article is from the "Learning Path" blog, please be sure to keep this source http://jicki.blog.51cto.com/1323993/1606232

CentOS 7 x64 Docker preliminary interview

Related Article

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.