CentOS7 install docker
Docker is an open source commercial product with two versions: Community Edition (Community Edition, abbreviated as CE) and Enterprise Edition (Enterprise Edition, abbreviated as EE). The enterprise version includes some paid services, which are generally not used by individual developers. The following introductions are all for the community edition.
For detailed instructions on installing the Docker environment, refer to the official document: https://docs.docker.com/get-docker, taking CentOS as an example.
1. Install the required software packages to install the yum-utils package
yum install -y yum-utils
2. Set up Ali repository
yum-config-manager \
--add-repo \
http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
3. Install docker
yum install docker-ce docker-ce-cli containerd.io
4. Docker related commands
view version
docker version
start docker
systemctl start docker
stop docker
systemctl stop docker
check status
systemctl status docker
restart service
systemctl restart docker
Set boot
systemctl enable docker
5. Configure mirroring
Docker pulls the image from here by default (https://hub.docker.com), and the speed of pulling from foreign addresses is relatively slow. We can also configure domestic mirror sources.
Aliyun image accelerator access address: https://help.aliyun.com/document_detail/60750.html, enter the container image service console to create an accelerator.
edit file config file
vim /etc/docker/daemon.json
add content
<Mirror Accelerator Address> Obtained from Alibaba Mirror Accelerator
{
"registry-mirrors": ["<镜像加速器地址>"]
}
Restart Docker Daemon
systemctl daemon-reload
6. Modify the docker default port
Modify the configuration file
vim /usr/lib/systemd/system/docker.service
add -H tcp://0.0.0.0:2375
default allocation
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
Modified configuration
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2375 --containerd=/run/containerd/containerd.sock
restart docker
systemctl restart docker