Introduction to the Docker of Docker learning notes _docker

Source: Internet
Author: User
Tags docker ps docker hub docker run

Some Questions about learning

    1. How do I heat update mirrors (images)? (You can quickly start or destroy the container.) This time is almost real-time.
    2. How to hot update the game suit?
    3. The advantage is that the environment of each application is independent of each other, even if a container crashes will not affect other containers;
    4. How do you maintain each container using ports? (Method 1 is written in dockerfile, not flexible; Method 2 is specified at run time);
    5. That way, there will be a lot of Linux users, the equivalent of each container to maintain a physical machine (virtual);
    6. Need a set of tools to manage the maintenance of mirrors, container operation and status;

What is the current mainstream use of Docker in which scenarios?

1. Docker's two software

Docker: Open source container virtualization platform;
Docker Hub:software-as-a-service platform for sharing and managing Docker containers.

2. Three major modules of Docker

Docker images. Mirror
Docker registries. Warehouse
Docker container. Container

3. Common commands

3.1. Common Mirror commands

Docker image (view mirror information)
Docker build (Create mirror)
Dockerfile
' #注释 '
From which Mirror is based
Maintainer defender Information
Run running instructions
ADD Copy local file to mirror
Expose set Open ports
The program allowed after the CMD container starts
Workdir Switch Working directory
-T Add tag
Path required after build

3.2. Use less mirroring command

Docker pull (get mirror)
Docker push (upload mirror)
Docker search (Searching for mirrors)
-S N searches only for mirrors above a specified star
Docker RMI (remove mirror)
Docker tag [id] [New Name:tag] (Modify tag)
Docker Save (Save Mirror)
Docker load (load mirror)
Docker load--input Xxx.tar
Docker Load < Xxx.tar
The difference between load and import, mirroring is complete and the snapshot is discarded for historical and meta data information
Docker RMI $ (Docker images-q-F "dangling=true") (Clean up any local mirrors that have not been labeled)

3.3. Commonly used container command

Docker run ([Download mirror and] start container)
-T assign a pseudo terminal
-I open standard input
-D Background Run
-V to create and mount a data volume (multiple)
--volumes-from mount a data volume (can have multiple)
-p Specifies the mapping port (ip:port:containerport/udp|ip::containerport|port:containerport)
-P Random Map port
--name Custom Container Name
Delete container immediately after--rm termination
--link: Container Interconnection
Docker start (start terminated container)
Docker Stop (End container)
Nsenter (Enter the container) (recommended)
pid=$ (Docker inspect--format "{{. State.pid}} ")
Nsenter--target $PID--mount--uts--ipc--net--pid

3.4. Use less container command

Docker commit (Submission container)
-M--massage= "" Submit information
-A--author= "" Author information
-P suspend container run when--pause=true commits
Docker Attach (Enter container)
Docker PS (view the running container)
-A view terminated
Docker logs [container ID or NAMES] View (background) run log
Docker export (exported container as file)
Docker Export > Xxx.tar
Docker Import (file snapshot import Mirror)
Cat Xxx.tar | Docker import-test/name:v1.0
Docker Import http://xxx.tgz Test/name
Docker RM (Delete container)
The container in operation is not deleted by default
Docker RM $ (Docker ps-a-Q) Cleans up all containers in the terminated state
-V deleting data volumes simultaneously

4. Installation

4.1. Install in CentOS7

Curl-ssl https://get.docker.com/| SH    //download robes scripts follow
chkconfig docker on              //set to boot automatically


4.2. Install in CentOS6

4.2.1. Add Yum Software source


Tee/etc/yum.repo.d/docker.repo << ' EOF '
[Dockerrepo]
name=docker Repository
baseurl=https:// yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https:// YUM.DOCKERPROJECT.ORG/GPG
EOF

4.2.2. Install Docker

Yum update
yum install-y docker-engine

4.2.3. No module named Yum

If no module named Yum error occurred while executing yum update, it may be caused by a Python version that does not correspond to Yum. You can specify the Python version by modifying the annotations of the Yum and yum-updatest execution scripts (/usr/bin/yum and/usr/bin/yum-updatest). Such as:

#!/usr/bin/python
Amended to
#!/usr/bin/python2.6

5. Basic Environment

You can download the Bashrc_docker file and load it into the environment. BASHRC, it can provide some convenient commands to do some more complicated process.

. Bashrc_docker (Https://raw.githubusercontent.com/yeasy/docker_practice/master/_local/.bashrc_docker) defines the following command

-Docker-pid (Get container pid)
-Docker-enter (Enter container)
Download and load into the Linux environment:

Wget-p ~ Https://raw.githubusercontent.com/yeasy/docker_practice/master/_local/.bashrc_docker
echo "[F ~/.bashrc_docker] &&. ~/.bashrc_docker ">> ~/.bashrc;source ~/.BASHRC

6. Warehouse

6.1. Private Warehouse

The robes provides a docker-registry mirror image for a private warehouse build.

Docker run-d-P 2010:5000 Registry

Vi/etc/docker/daemon.json
{"insecure-registries": [" myregistry.example.com:5000 "]}

Cul http://x.x.x.x:2010/v2/linerl/tags/list

API Documentation: HTTPS://GITHUB.COM/DOCKER/DISTRIBUTION/BLOB/MASTER/DOCS/SPEC/API.MD

7. Some conclusions after the study

itself is the virtual machine technology implementation of the server most with the nature of scalable upgrades at any time, there is no need for resource allocation, there is no need to use Docker;
Docker is suitable to do load balanced short link Web service above, the application scene is to mirror, the container is the best operation unit;
If there is a business can be mirrored, container maintenance can be, that this business is suitable for the use of Docker.

Above only I just started to learn some understanding, of course Docker ability I still far did not understand, the suitable scene certainly also has many. The current records are only for future inspection and learning consolidation.

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.