Docker

Posted bosaidongmomo

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker相关的知识,希望对你有一定的参考价值。

安装Docker

1.制作docker路径

mkdir /home/docker

2.解压并安装

tar zxf docker-20.10.6.tgz

3.复制到环境中

cp docker/* /usr/bin/

4.注册服务

cat >/etc/systemd/system/docker.service <<-EOF
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[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 tcp://0.0.0.0:2375 -H unix://var/run/docker.sock
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
EOF

5.修改可执行权限

chmod +x /etc/systemd/system/docker.service

6.刷新服务

systemctl daemon-reload

7.关闭docker

systemctl stop docker

8.打开docker

systemctl start docker

9.开机服务启动

systemctl enable docker.service

10.查看当前镜像

docker images

安装docker-compose

curl -L https://get.daocloud.io/docker/compose/releases/download/1.25.4/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose -v

以上是关于Docker的主要内容,如果未能解决你的问题,请参考以下文章

Docker教程-1-学习及安装Docker

Docker教程-1-学习及安装Docker

Docker03 Docker基础知识Docker实战

Docker学习__docker命令[docker version 和 docker info]

[转帖]Docker里运行Docker docker in docker(dind)

docker 定时清理docker容器日志