Some considerations in the process of Docker use _docker

Source: Internet
Author: User
Tags docker run

Objective

Docker is not a new technology, the container is not, as early as in 2006, there have been lxc, openvz,jail and other container virtualization technology, but why Docker can be a sudden rise? The core of Docker is the Linux Cgroup, namespace, and Layeredfs technology, through resource control, isolation, and layering of mirrors, where the Docker container can package the application and the operating environment together so that it can build and ship and Run anywhere. It is not so much a docker fire as its innate lightweight nature that caters to the cloud's path today. Therefore, I think Docker change the whole cloud computing and the pattern of the Internet is a matter of sooner or later, but Docker in use, need to pay attention to what matters?

One, Mount volumes

docker run, if you need to mount a directory of host hosts, you can

Docker Run-it-v  
 

Here are a few places to note:

1, and <container-path> all must be directory

2, <container-path> must be the absolute path in the container

3, If the path does not exist, after execution completes, Docker will create the directory for the host, you can use a relative path, but not the current working directory, but the/var/lib/docker/volumes/

4, if there is only one path, for example docker run -it -v <path> <image> , this situation is called anonymous mount, <image> represents the location in the container, the host will randomly create a directory under/var/lib/docker/volumes/and container in the <path> corresponding

5, in any way mount , after the container is destroyed, the -v directory created on the host will not be destroyed

6. In container, you can modify the properties of the file under the Mount directory, and it will take effect as viewed on the host. It should be noted, however, that if the owner of the file was modified in container, the owner of this file was not necessarily John when it was produced on the host. But the UID of the file is the same, as the name of the display is not the same, because the container and host's/etc/passwd file content is different

All of the above results can be docker inspect <container> viewed in the results Mounts .

Ii. entrypoint and CMD in the Dockerfile

Looks like it's all about implementing the container startup command, but note:

1, there are two ways, array mode, and Shell mode

["Sh", "-C", "echo Hello"]
Sh-c ' echo Hello '

2, EntryPoint In addition to the designated container entrance, the more important role is: through it can make a container like a executable. Like what

entrypoint ["/bin/sh"]

After the build of the mirror like a sh program file, run the image, just like running the SH program.

3, if the entrypoint specified, and the array method, that is ["exectable", "para1", "para2"] , the CMD specified content will be treated as the last parameter in the entrypoint array

4, if the entrypoint uses the Shell method, then it will overwrite all CMD as well as the docker run command specified later

5, docker run the command specified later will replace the contents of CMD

Summarize

The above is for you to sum up some individuals in the use of Docker has fallen out of the pit, hope to share out so that everyone in the use of Docker can avoid these problems, the above is the entire content of this article, I hope to help you.

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.