Simple installation of docker

The original meaning of Docker in English is "porter". In the programmer's world, Docker transports containers (Containers), which contain any type of App. Through Docker, developers can turn the App into a standardized, Portable, self-managing components that can be developed, debugged and run on any mainstream system. Most importantly, it does not depend on any language, framework or system.

Docker is an open source engine that makes it easy to create a lightweight, portable, self-sufficient container for any application. Containers that developers compile and test on laptops can be deployed in production environments in batches, including VMs (virtual machines), bare metal, OpenStack clusters and other basic application platforms.

Docker is usually used in the following scenarios:

web应用的自动化打包和发布;
自动化测试和持续集成、发布;
在服务型环境中部署和调整数据库或其他的后台应用;
从头编译或者扩展现有的OpenShift或Cloud Foundry平台来搭建自己的PaaS环境。

The Docker system has two programs: the docker server and the docker client. The docker server is a service process that manages all containers. The docker client acts as a remote controller for the docker server and can be used to control the docker server process. In most cases, the docker server and client run on the same machine.

Install the docker environment (rhel7.2)
1) Modify the yum source to install the docker engine

vim /etc/yum.repos.d/yum.repo, 加入以下内容:

[dockerrepo]
name=Docker Repository
baseurl=http://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=0

Based on the computer can be connected to the Internet. . . .
However, just like my virtual machine, I can't connect to the network, so I can only use the local yum source to install the dependencies after downloading the installation package.
The process is as follows:
[root@server3 ~]# rpm -ivh docker-engine–1.13.1-1.el7.centos.x86_64.rpm
warning: docker-engine-1.13.1-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
error: Failed dependencies:
libltdl.so.7()(64bit) is needed by docker-engine-1.13.1-1.el7.centos.x86_64
libseccomp.so.2 ()(64bit) is needed by docker-engine-1.13.1-1.el7.centos.x86_64
selinux-policy-base >= 3.13.1-102 is needed by docker-engine-selinux-1.13.1-1. el7.centos.noarch
selinux-policy-targeted >= 3.13.1-102 is needed by docker-engine-selinux-1.13.1-1.el7.centos.noarch
At this time, libseccomp.x86_64 and libtool-ltdl.x86_64 were installed using yum, which solved the above two dependencies. However, the computer yum source could not meet the version requirements of selinux-* during installation, so the Internet could not be accessed. I reduced the version of docker to rpm -ivh docker-engine-1.12.6-1.el7.centos.x86_64.rpm docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm this time Installation was successful.

[root@server3 ~]# rpm -ivh docker-engine-1.12.6-1.el7.centos.x86_64.rpm docker-engine-selinux-1.12.6-1.el7.centos.noarch.rpm
warning: docker-engine-1.12.6-1.el7.centos.x86_64.rpm: Header V4 RSA/SHA512 Signature, key ID 2c52609d: NOKEY
Preparing...                                                            ################################# [100%]
Updating / installing...
   1:docker-engine-selinux-1.12.6-1.el                                  ################################# [ 50%]
setsebool:  SELinux is disabled.
libsepol.permission_copy_callback: Module docker depends on permission audit_read in class capability2, not satisfied (No such file or directory).
libsemanage.semanage_link_sandbox: Link packages failed (No such file or directory).
/usr/sbin/semodule:  Failed!
   2:docker-engine-1.12.6-1.el7.centos                                  ################################# [100%]

2) Turn on the routing forwarding function, otherwise the container in the container cannot access the Internet

echo 1 > /proc/sys/net/ipv4/ip_forward

3) Start the Docker service

 systemctl start docker

 systemctl enable docker   #开机启动

4) Check if the installation is successful

 docker version    #可查看docker版本信息则安装成功。
 [root@server3 ~]# docker version
Client:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   78d1802
 Built:        Tue Jan 10 20:20:01 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.12.6
 API version:  1.24
 Go version:   go1.6.4
 Git commit:   78d1802
 Built:        Tue Jan 10 20:20:01 2017
 OS/Arch:      linux/amd64

5) docker info #View the overall status of containers in Docker.

[root@server3 ~]# docker info
Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 1.12.6
Storage Driver: devicemapper
 Pool Name: docker-253:0-68326981-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 11.8 MB
 Data Space Total: 107.4 GB
 Data Space Available: 17.56 GB
 Metadata Space Used: 581.6 kB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.147 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.107-RHEL7 (2015-10-14)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: host bridge overlay null
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-327.el7.x86_64
Operating System: Red Hat Enterprise Linux Server 7.2 (Maipo)
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 993.1 MiB
Name: server3
ID: 4K4S:EPX4:ZQ4Y:XHD7:5GAW:ETCN:QWUE:SISI:A3KF:NPAX:QFP3:PQJ3
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Insecure Registries:
 127.0.0.0/8

The following content comes from the Internet for easy understanding:

  1. Docker overview:
    Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable container, which can then be distributed to any popular Linux machine, and can also be virtualized. Containers are completely sandboxed and do not have any interface with each other (similar to iPhone apps). There is almost no performance overhead and can be easily run in machines and data centers. Most importantly, they do not depend on any language, framework or packaging system.
    Docker is an LXC-based advanced container engine open sourced by dotCloud. The source code is hosted on Github, based on the Go language and open sourced under the Apache2.0 protocol.
    Docker allows developers to package their applications and dependencies into a portable container that can then be distributed to any popular Linux machine.

    The relationship between Image and Container: Image can be understood as a system image, and Container is a state of Image at runtime. If you take a virtual machine as an analogy, Image is the disk file in the shutdown state, and Container is the disk file when the virtual machine is running, including memory data.
    dockerhub: dockerhub is the official image storage site of docker, which provides many commonly used images for users to download, such as ubuntu, centos and other system images. Users can also publish their own docker images through dockerhub. For this, users need to register an account and create a docker warehouse on the website.

  2. Docker core technology
    1) Namespace - realizes the isolation of Container's process, network, message, file system and host name.
    2) Cgroup - implements quotas and metrics for resources. The quota of Cgrout is like the configuration parameters in the vmware virtual machine: you can specify the number of cpus, memory size, etc.

  3. Docker features
    File system isolation: Each process container runs in a completely independent root file system.
    Resource isolation: System resources, such as CPU and memory, can be allocated to different containers using cgroups.
    Network isolation: Each process container runs in its own network space, virtual interface and IP address.
    Logging: Docker will collect and log standard streams (stdout/stderr/stdin) per process container for real-time retrieval or batch retrieval.
    Change Management: Changes to a container's filesystem can be committed to a new image and reused to create more containers. No templates or manual configuration required.
    Interactive shell: Docker can assign a virtual terminal and attach it to any container's standard input, e.g. to run a one-time interactive

  4. Docker pros and cons:

    Advantages:
    1) Some advantages are the same as VMs, but not all. Smaller than VMs and faster than VMs, the reduced size of Docker containers greatly simplifies distribution to and from the cloud time and overhead compared to entire virtual machines. Docker starts a container instance in a very short time, and an instance can be started in a second or two.
    2) IT releases faster for running the same unchanged application on laptops, virtual machines in the data center, and any cloud. Docker is an open platform for building, publishing and running distributed applications. Docker enables applications to be quickly assembled from components and avoid friction between development and production environments.
    3) You can use it when deployed on company LAN or cloud or virtual machine.
    4) Developers don't care which specific Linux OS uses Docker, developers can build the corresponding software based on all dependencies, targeting the OS of their choice. Then, when deploying, everything is exactly the same, because everything runs on the DockerImage's container. The developer is responsible and able to ensure that all dependencies are met.
    5) Google, Microsoft, Amazon, IBM, etc. all support Docker.
    Disadvantages:
    1) Docker supports Unix/Linux operating system, Windows or Mac need to rely on Boot2Docker.
    2) Docker is most useful when used for applications, but does not contain data. Logs, traces, databases, etc. should generally be placed outside the Docker container.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325811682&siteId=291194637