赞
踩
如果你无法使用Docker’s apt repository 安装 Docker Engine,你可以下载deb文件然后手动安装。
containerd.io_<version>_<arch>.deb
docker-ce_<version>_<arch>.deb
docker-ce-cli_<version>_<arch>.deb
docker-buildx-plugin_<version>_<arch>.deb
docker-compose-plugin_<version>_<arch>.deb
sudo dpkg -i ./containerd.io_1.4.12-1_amd64.deb \
./docker-ce_20.10.10_3-0_ubuntu-bionic_amd64.deb \
./docker-ce-cli_20.10.10_3-0_ubuntu-bionic_amd64.deb \
./docker-buildx-plugin_0.10.2-1_ubuntu.18.04_bionic_amd64.deb \
./docker-compose-plugin_2.10.2_ubuntu-bionic_amd64.deb
docker daemon会自启动,用docker ps
命令验证
# 先停掉服务
systemctl stop docker
# 备份docker.service
cp /lib/systemd/system/docker.service /lib/systemd/system/docker.service-bak
# 修改/lib/systemd/system/docker.service文件添加如下
ExecStart=/usr/bin/dockerd -g /home/dorahou/docker -H fd:// --containerd=/run/containerd/containerd.sock
# 启动服务
systemctl start docker
docker.service参考文件,如果版本与我一致可直接拷贝替换
[Unit] Description=Docker Application Container Engine Documentation=https://docs.docker.com After=network-online.target firewalld.service containerd.service Wants=network-online.target Requires=docker.socket containerd.service [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 ExecStart=/usr/bin/dockerd -g /home/dorahou/docker -H fd:// --containerd=/run/containerd/containerd.sock ExecReload=/bin/kill -s HUP $MAINPID TimeoutSec=0 RestartSec=2 Restart=always # Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229. # Both the old, and new location are accepted by systemd 229 and up, so using the old location # to make them work for either version of systemd. StartLimitBurst=3 # Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230. # Both the old, and new name are accepted by systemd 230 and up, so using the old name to make # this option work for either version of systemd. StartLimitInterval=60s # 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 # Comment TasksMax if your systemd version does not support it. # Only systemd 226 and above support this option. TasksMax=infinity # 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 OOMScoreAdjust=-500 [Install] WantedBy=multi-user.target
# 先停掉服务
systemctl stop docker
# /etc/docker/目录下创建daemon.json文件
touch daemon.json
daemon.json文件参考如下:
{
"registry-mirrors":["https://regustrt,dicjer-cn.com"],
"dns":["8.8.8.8","114.114.114.114"],
"log-driver":"json-file",
"log-opts":{"max-size":"200m","max-file":"3"}
}
# 启动服务
systemctl start docker
# 查看在运行容器
docker ps
# 查看所有容器
docker ps -a
# 查询容器日志
docker logs {container} --tail 1000
# 启动一个新容器,最后的nginx表示镜像名
docker run -it --name=nginx --net=host -v /home/dorahou/nginx/conf.d:/etc/nginx/conf.d -v /home/dorahou/nginx-logs:/var/log/nginx -v /home/dorahou/nginx/nginx.conf:/etc/nginx/nginx.conf -v /home/dorahou/vpc:/home/dorahou/vpc nginx
docker run --name snapshot-offline -it --net=host -v /home/dorahou:/home/dorahou -v /home/dorahou/vpc:/home/dorahou/vpc --entrypoint bash snapshot-server:latest
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。