docker.service 修改指南
vi /lib/systemd/system/docker.service
docker.service
默认内容如下:
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service containerd.service
Wants=network-online.target
Requires=docker.socket
[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
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
[Install]
WantedBy=multi-user.target
下面的配置都是在[Service]
节点下的ExecStart
属性后面加参数值,docker.service
文件被修改后请执行systemctl daemon-reload && systemctl restart docker
,如果配置未生效,请执行systemctl status docker
查看服务状态。
开启远程API访问端口
添加-H 0.0.0.0:2375
,端口可以随意指定,修改后的ExecStart
如下:
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H 0.0.0.0:2375
重新加载配置并重启docker
systemctl daemon-reload && systemctl restart docker
访问http://127.0.0.1:2375/info
进行验证
修改bridge
网络的ip段
执行docker network inspect bridge
命令可以发现bridge
网络默认的IP段是172.17.0.0/16
,添加--bip 10.0.0.1/16
修改默认IP段
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --bip 10.0.0.1/16
重新加载配置并重启docker
systemctl daemon-reload && systemctl restart docker
启动一个nginx
容器进行验证
docker run -dP --name nginx nginx
docker inspect --format '{{ .NetworkSettings.IPAddress }}' nginx
docker rm -f nginx
配置私有镜像仓库
以下示例配置develop-harbor.geostar.com.cn
,test-harbor.geostar.com.cn
,release-harbor.geostar.com.cn
三个私有镜像仓库
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock \
--insecure-registry develop-harbor.geostar.com.cn \
--insecure-registry test-harbor.geostar.com.cn \
--insecure-registry release-harbor.geostar.com.cn \
重新加载配置并重启docker
systemctl daemon-reload && systemctl restart docker
手动拉取私有镜像仓库中的镜像验证
配置dns
以下示例配置114.114.114.114
和8.8.8.8
两个dns服务器地址
ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock \
--dns 114.114.114.114 \
--dns 8.8.8.8
重新加载配置并重启docker
systemctl daemon-reload && systemctl restart docker
启动一个alpine
容器镜像验证resolv.conf
配置文件是否成功修改
docker run --rm alpine cat /etc/resolv.conf
docker.service 修改指南的更多相关文章
- Linux Mint安装Docker踩坑指南
我家的服务器选用的Linux Mint系统,最近安装Docker的时候踩了一些小坑,但是总体还算顺利. 我们都知道Linux Mint系统是基于Ubuntu的,说实话用起来感觉还是很不错的,安装Doc ...
- docker日常使用指南
docker日常使用指南 目录 docker日常使用指南 前言 1.基础知识 1.1 docker是什么 1.2 与虚拟机(VM)的区别 1.3 镜像与容器 2.安装 2.1 在线安装 2.2 离线安 ...
- Docker - 通过swarm 管理 docker service
创建一个 Docker service $ docker service create --replicas 1 --name myhelloworld alpine ping docker.com ...
- CentOS启动docker1.13失败(Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.)
一.启动失败 1.启动docker [root@localhost ~]# systemctl start docker Job for docker.service failed because t ...
- Failed to start docker.service: Unit not found.
安装教程参考: https://docs.docker.com/install/linux/docker-ce/centos/#install-docker-ce-1 https://yq.aliyu ...
- Docker(十七)-修改Docker容器启动配置参数
有时候,我们创建容器时忘了添加参数 --restart=always ,当 Docker 重启时,容器未能自动启动, 现在要添加该参数怎么办呢,方法有二: 1.Docker 命令修改 docker c ...
- docker探索-使用docker service管理swarm(十一 )
本文转自:https://www.cnblogs.com/atuotuo/p/6265541.html 1.创建一个 Docker service $ docker service create -- ...
- Docker: 如何修改 Docker 的镜像存储位置
我用的阿里云的服务器, 但是系统盘只有20G, 默认 Docker 的镜像文件是安装在/var/lib 目录下的, 这样的话我根本装不了太多的镜像... 这个必须得改改... 搜了下, 解决方案如下: ...
- CentOS7 启动docker.service失败(code=exited, status=1/FAILURE)
启动报错 Job for docker.service failed because the control process exited with error code. See "sys ...
随机推荐
- 2019-11-20-dotnet-Blazor-用-C#-控制界面行为
title author date CreateTime categories dotnet Blazor 用 C# 控制界面行为 lindexi 2019-11-20 18:26:25 +0800 ...
- 1月房地产企业销售TOP100出炉 万科重回第一
1月房地产企业销售TOP100出炉 万科重回第一 2017-02-05 07:40:32 来源:腾讯新闻 责任编辑: [摘要]TOP100房企1月的销售金额合计4311.8亿元,销售面积合计3648. ...
- @游记@ THUWC2019
目录 @day -???@ @day -30~-1@ @day 0@ @day 1@ @day 2@ @day 3@ @day -???@ 我这个蒟蒻居然收到了 THUWC 的邀请? 那就去试试运气吧 ...
- 全文索引——CONTAINS 语法
Like直接在数据据中查找可以查到所有所需记录但是会扫描整个表会影响性能CONTAINS是基于全文索引进行查询,查询结果受系统全文索引分词的方法影响查询结果会不全.Select * FROM A Wh ...
- 学习C#泛型
C#泛型详解 C#菜鸟教程 C#中泛型的使用
- AtCoder Regular Contest 059
C - いっしょ / Be Together 数据比较小,暴力就挺好的.O(n^2)可过的好题 #include <bits/stdc++.h> using namespace std; ...
- .net core 文件下载
public IActionResult Dowanload(string id,int numTypes) { try { var memory = new MemoryStream(): //mo ...
- hdu 1708 Fibonacci String
Fibonacci String Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Tot ...
- hdu 1016 Prime Ring Problem(dfs)
Prime Ring Problem Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...
- java线程与进程的比较
线程具有许多传统进程所具有的特征,故又称为轻型进程(Light—Weight Process)或进程元:而把传统的进程称为重型进程(Heavy—Weight Process),它相当于只有一个线程的任 ...