Due to company reasons, ubuntu cannot be used in production and can only use Centos, so the basis of this article is Centos.
Centos6.x definitely does not recommend installing docker for the following reasons:
The operating requirements of docker can only be met by upgrading the kernel, but there is a risk that the kernel cannot be turned on when the kernel is upgraded.
Even if the upgrade is successful, it is extremely unstable when running the container and will stop for no reason (the company's historical experience summed up, it may be caused by unfamiliar with docker, if someone solves it, you can reply to me, thank you very much);
Devicemapper uses lvm, which has low performance.
The setting of this article is to use Centos 7.4 version, the kernel is 3.10.0.
Check whether the centos-extras library is enabled. The default is enabled. If it has not been modified, skip this step.
Check if the memory is enough, the minimum is 4G
Install the dependent libraries. Note that the 18.01.0 version of docker does not require additional devicemapper configuration. You can use lvm2 by executing the following commands to avoid poor lvm performance.
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
- - add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
Note: If the stable library is recommended for production, if you want to use edge or test, execute the following command to enable
yum-config-manager --enable docker-ce-edge
yum-config-manager --enable docker-ce-test
systemctl stop firewalld.service #stop
systemctl disable firewalld.service #Disable
At the current time, the latest version of 2018-01-31 is 18.01.0, you can directly execute the following command to install
yum install docker-ce
If the latest version is greater than 18.01.0, you can install it as follows
yum list docker-ce --showduplicates | sort -r
Note that the first column is the name, the second column is the version, and the third column is the name of the resource library. Generally, stable is a stable library, edge is an edge library, and test is a test library. The stable library must be selected in the production environment, otherwise it will be unavailable. Problems foreseen.
yum install <FULLY-QUALIFIED-PACKAGE-NAME>
Note: The package name is a combination of intercepting partial values in the first column and the second column. For example, the list is as follows
docker-ce.x86_64 18.01.0.ce-1.el7.centos docker-ce-stable
Then the package name should be docker-ce-18.01.0.ce
After the installation is complete, do not start it yet, because the default docker image is a foreign country, the download speed may be slower, click the following link: https://www.daocloud.io/mirror#accelerator-doc, if you need to log in, please register first. Then click again to get the accelerator code, and then copy it to the machine to run.
After the accelerator is set up, execute the following command to start docker
systemctl start docker
If the startup fails, enter the following command to view the reason for the startup failure
systemctl status docker
docker -v
docker info
docker start <container name | id>
docker stop <container name | id>
docker rm <container name | id>
docker ps -a
docker ps
docker exec -t -i <container name| id> bash
systemctl start docker
systemctl stop docker
systemctl restart docker
docker logs -f <container name|id>
docker commit -m "jre8"-a "scc"Container id image[:tag]
docker images
docker system prune -a
Novice tutorial: http://www.runoob.com/docker/docker-command-manual.html
A good detailed explanation on CSDN: http://blog.csdn.net/permike/article/details/51879578
Recommended Posts