Docker introduction

Source: Internet
Author: User

Docker installation configuration
System version (centos 6.5x64)

Introduction: Docker is an open-source application container engine that allows developers to package their applications and dependencies to a portable container and then publish them to any popular Linux machine, you can also achieve virtualization. Containers fully use the sandbox mechanism and do not have any interfaces (similar to iPhone apps) between them ). With almost no performance overhead, it is easy to run on machines and data centers. Most importantly, they do not rely on any language, framework, or systems.


1. Install EPEL
Rpm-ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

2. Install Docker
Yum-y install docker-io
Service docker start
Chkconfig docker on


III. Simple Docker operations
1. Get Centos image
Docker pull centos: latest // download the final centos version Image
Docker pull centos: centos6 // download the centos6 image
2. View the image running status
Docker images centos // view a separate centos image
Docker images // view all downloaded images
3. Run shell bash in the container
Docker run-I-t <IMAGE ID>/bin/bash // <IMAGE ID> obtained from the docker images command
4. Start the container
Docker start <container id> // <container id> obtained from the docker ps-a command
5. Stop the container
Docker stop <container id> // <container id> obtained from the docker ps-a command
6. View container logs
Docker logs-f <container id>
7. Delete all containers
Docker rm $ (docker ps-a-q)
8. Delete an image
Docker rmi <image id> // <image id> obtained from the docker images command


4. Docker application operations
1. Submit the container changes to the image repository and run hello. sh in the container.

Docker images // view the image

650) this. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4D/E5/wKiom1RcMQrSxPJkAADCoJ6kxto126.jpg "title =" 01.jpg" alt = "wKiom1RcMQrSxPJkAADCoJ6kxto126.jpg"/>

Docker run-I-t 70441cac1ed5/bin/bash // enter the container

650) this. width = 650; "src =" http://s3.51cto.com/wyfs02/M01/4D/E4/wKiom1RcJweiysntAAGurg62f9Q418.jpg "title =" 002.jpg" alt = "wKiom1RcJweiysntAAGurg62f9Q418.jpg"/>

Docker commit <container id> testuser/centos // Save the changed image as testuser/centos image name

<Container id> // The ID of the CONTAINER you just opened. The circle is red. 650) this. width = 650; "src =" http://s3.51cto.com/wyfs02/M00/4D/E3/wKioL1RcKQuyeJ4zAAESxZSsf10077.jpg "title =" 003.jpg" alt = "wKioL1RcKQuyeJ4zAAESxZSsf10077.jpg"/>

Docker run-I-t testuser/centos/bin/sh/home/testuser/hello. sh // if the execution shows hello docker !!!, Indicates that the docker test is successful.

650) this. width = 650; "src =" http://s3.51cto.com/wyfs02/M02/4D/E4/wKiom1RcKYHA8osVAAB6rjPTHKQ146.jpg "title =" 04.jpg" alt = "wkiom1rckyha8osvaab6425pthkq146.jpg"/>

2. Create and test an image with the nginx service
Docker run-I-t <IMAGE ID>/bin/bash // <IMAGE ID> obtained from the docker images command
Exit
Docker commit <container id> nginx/centos // Save the changed image as the nginx/centos image name
Docker run-I-t nginx/centos/bin/bash
<Install the nginx software package. For details, Baidu> // The installation environment is the same as usual.
// Add daemon off in the nginx. conf configuration file header;
Exit
Docker commit <container id> nginx/centos // Save the changed image as the nginx/centos image name
Start Nginx in Docker
Docker run-d-p 80: 80 nginx/centos/usr/local/m1905/nginx/sbin/nginx // 1st port 80 is the port mapped to the physical machine, the 2nd port 80 is the nginx service port in the docker container.

5. Import and export images
1. Export an image
Docker save-o nginx.tar nginx/centos // nginx.tar indicates the name of the image backup, and nginx/centos indicates the name of the image to be exported.
2. Import to the new virtual machine environment
Docker load -- input nginx.tar // nginx.tar indicates the image backup name.
Docker images // check whether the image has been imported successfully

This article from the "Chengdu @ a like" blog, please be sure to keep this source http://azhuang.blog.51cto.com/9176790/1573927

Docker introduction

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.