Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to deploy Docker in Centos6.5

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article will explain in detail how to deploy Docker in Centos6.5. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.

1. Prepare to disable selinux [optional]

Because of the conflict between Selinux and LXC, it is necessary to disable selinux. Edit / etc/selinux/config and set two key variables.

SELINUX=disabled

SELINUXTYPE=targeted

Note: there are tutorials on the Internet that say to set up, but I recommend not to set it, because it will affect security.

Install Fedora EPEL source yum install http://ftp.riken.jp/Linux/fedora/epel/6/x86\_64/epel-release-6-8.noarch.rpm

Add hop5.repo source cd / etc/yum.repos.dwget http://www.hop5.in/yum/el6/hop5.repo2.yum install and upgrade 3.10 kernel with aufs module [optional] yum install kernel-ml-aufs kernel-ml-aufs-devel

Modify the main configuration file / etc/grub.conf of grub, and set default=0 to indicate that the content under the first title is the kernel started by default (usually the newly installed kernel is in the first location):

Check to see if the kernel supports aufs:

Install docker

Installation dependencies:

Yum install redhat-lsb yum install device\-mapper-libsyum install libcgroup\ *

If the following error occurs:

The solution is to edit / etc/yum.repos.d/epel.repo and comment out the address of basic recovery (baseurl) and mirrorlist (image):

If the following error occurs:

Start docker

Execute the following command to start docker:

Service docker start

Solution: execute the following command to delete docker-io

Sudo yum remove docker-io

Note: download address of installation package: https://yum.dockerproject.org/repo/main/centos/6/Packages/

Execute the following command again to start docker:

Service docker start

View docker Log

Cat / var/log/docker

Note: start represents popularity. OFFICIAL stands for the official version

View all current mirrors

Docker images

Download the image

Docker pull centos

Run the container

Docker run centos echo "hello word"

Run Container hello word

Docker run hello-world

After you print this prompt, the hello world stops running and the container terminates automatically.

4. Delete

You can use yum to delete docker

Query delete docker

1. List the specific name of the docker package

$sudo yum list installed | grep dockercontainerd.io.x86\ _ 64 1.2.4\-3.1.el7 docker\-ce.x86\ _ 64 3VR 18.09.3\-3.el7docker\-ce-cli.x86\ _ 64 1mer 18.09.3\-3.el7

two。 Delete docker

$sudo yum-y remove containerd.io.x86\ _ 64\\ docker\-ce.x86\ _ 64\\ docker\-ce-cli.x86\ _ 64 directly delete dockersudo yum remove docker\\ docker\-io\\ docker\-client\\ docker\-client-latest\\ Docker\-common\\ docker\-latest\\ docker\-latest-logrotate\\ docker\-logrotate\\ docker\-engine

Note: the above command will only delete the docker runtime environment, not images, containers, volume files, and user-created configuration files.

Clear the image and container files:

Sudo rm-rf / var/lib/docker

Manually find and delete user-created profiles.

5. Note 5.1. Manually mount cgroup

For a lower version of Redhat, you may need to mount cgroup manually, as follows:

Preferred to disable cgroup corresponding service cgconfig

Service cgconfig stop # shutdown service chkconfig cgconfig off # cancel boot

Then mount cgroup, which can be mounted on the command line

Mount-t cgroup none / cgroup # is valid only this time

Or modify the configuration file, edit / etc/fstab, and join

None / cgroup cgroup defaults 0 0

5.2. Manage docker as a non-root user

The Docker daemon is bound to the Unix socket instead of the TCP port. By default, Unix socke is available only to root users, while other users can only use it by using sudo. The Docker daemon always runs as root.

If you do not want to add sudo before the docker command, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket that can be accessed by members of the docker group.

1. Create a docker group

Sudo groupadd docker

two。 Add user to the docker group

Sudo usermod-aG docker $USER

Please replace $USER with one of your users in the system other than root.

3. Log out and log back in to re-evaluate your group membership.

If you are testing on a virtual machine, you may need to restart the virtual machine for the changes to take effect.

4. Verify that you can run the docker command without using sudo.

Docker run hello-world

If you initially used sudo's Dokcer CLI command before adding users to the docker group. You may make the following error, indicating that your ~ / .docker directory has incorrect permissions created by the sudo command.

WARNING: Error loading config file: / home/user/.docker/config.json-stat / home/user/.docker/config.json: permission denied

To resolve this issue, delete the ~ / .docker / directory (it is automatically recreated, but any custom settings are lost), or use the following command to change its ownership and permissions:

$sudo chown "$USER": "$USER" > 5.3. Mirror acceleration

In view of the domestic network problems, it is very slow to pull the Docker image later, so we need to configure an accelerator to solve it.

Docker domestic image:

NetEase Accelerator: http://hub-mirror.c.163.com

Official China Accelerator: https://registry.docker-cn.com

Image of ustc: https://docker.mirrors.ustc.edu.cn

You can also use a private image accelerator address, such as using Aliyun's image accelerator: log in to Aliyun-> products-> search for "Container Image Service"-> Image Library-> Image Accelerator.

The new version of Docker uses / etc/docker/daemon.json (Linux) to configure Daemon.

Please add to the configuration file (if there is no such file, please create one first):

Vi / etc/docker/daemon.json {"registry-mirrors":\ ["https://hub-mirror.c.163.com"\]}"

After the configuration is successful, CentOS6.5 restarts:

Service docker restart on how to deploy Docker in Centos6.5 to share here, I hope the above content can be of some help to you, can learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report