我们可以更新docker默认配置吗?

时间:2016-03-08 05:47:42

标签: docker kubernetes configure

需要:

我需要将“ LogConfig ”类型更改为 syslog

我知道这可行:

  

docker run --log-driver = syslog

但是,我现在在集群中用k8s启动容器。如何配置LogConfig?或者如何将其默认更改为syslog?

感谢@Jan Garaj和@molivier

这是我的泊坞版

[root@ip-hostname ~]# docker version
Client:
 Version:      1.8.2-el7.centos
 API version:  1.20
 Package Version: docker-1.8.2-10.el7.centos.x86_64
 Go version:   go1.4.2
 Git commit:   a01dc02/1.8.2
 Built:
 OS/Arch:      linux/amd64

Server:
 Version:      1.8.2-el7.centos
 API version:  1.20
 Package Version:
 Go version:   go1.4.2
 Git commit:   a01dc02/1.8.2
 Built:
 OS/Arch:      linux/amd64

[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target
Wants=docker-storage-setup.service

此配置:

[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/docker
EnvironmentFile=-/etc/sysconfig/docker-storage
EnvironmentFile=-/etc/sysconfig/docker-network
Environment=GOTRACEBACK=crash
ExecStart=/usr/bin/docker daemon $OPTIONS='--log-driver=syslog' \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY
LimitNOFILE=1048576
LimitNPROC=1048576
LimitCORE=infinity
MountFlags=slave
TimeoutStartSec=1min
Restart=on-failure

[Install]
WantedBy=multi-user.target

然后:

  

systemctl daemon-reload

     

systemctl restart docker

看起来不行......

  

docker inspect 7fa2e28203b1

 "SecurityOpt": null,
        "ReadonlyRootfs": false,
        "Ulimits": null,
        "LogConfig": {
            "Type": "json-file",
            "Config": {}
        },
        "CgroupParent": "",
        "ConsoleSize": [
            0,
            0
        ]

请帮忙......

1 个答案:

答案 0 :(得分:2)

您可以在 / etc / default / docker daemon)中调整泊坞窗默认配置:

DOCKER_OPTS='
-H tcp://0.0.0.0:2376
-H unix:///var/run/docker.sock
--storage-driver aufs
.../...
--log-driver=syslog
'

查看configuring docker

编辑:正如Jan Garaj(issue 9889)所提到的,/ etc / default / docker文件仅用于使用“upstart”和“SysVInit”的系统,而不是在使用systemd的系统上使用(see systemd config )。