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 ...
随机推荐
- python命令之m参数 局域网传输
在命令行中使用python时,python支持在其后面添加可选参数. python命令的可选参数有很多,例如:使用可选参数h可以查询python的帮助信息: 可选参数m 下面我们来说说python命令 ...
- 使用模块定义AngularJS组件
一.模块创建/查找 module 当创建一个模块时,必须指定name和requires参数,即使你的模块并不存在依赖 var myApp=angular.module("exampleApp ...
- phpstorm IDEA 双击Shift键会弹出 SearchEverywhere 对话框,如何取消这个功能
https://blog.csdn.net/qq_27598243/article/details/80526352 解决方法:一:Open lib/resources.jar/idea/Platfo ...
- hdu 4146 Flip Game
Flip Game Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 65535/32768 K (Java/Others)Total ...
- 洛谷P1981 表达式求值 题解 栈/中缀转后缀
题目链接:https://www.luogu.org/problem/P1981 这道题目就是一道简化的中缀转后缀,因为这里比较简单,只有加号(+)和乘号(*),所以我们只需要开一个存放数值的栈就可以 ...
- H3C 帧中继与水平分割
- H3C 帧中继网络拓扑
- tf.shape()
tf.shapetf.shape( input, name=None, out_type=tf.int32)12345例如:将矩阵的维度输出为一个维度矩阵import tensorflow as tf ...
- 2018-8-10-git-提交添加-emoij-文字
title author date CreateTime categories git 提交添加 emoij 文字 lindexi 2018-08-10 19:16:52 +0800 2018-2-1 ...
- java构造方法的私有化
有的时候我们为了避免外界创建某类的实例,就将某类的构造方法私有化,即将它的构造方法用private修饰: 外界如何用到? 提供get方法!不提供的话外界就没法创建对象!(对反射无效) Eg:packa ...