2017-01-07 18 views
6

Tôi đang cố gắng thay đổi daemon.json trên Docker cho Windows (Windows 10 Aniversary cập nhật mới nhất được cài đặt) 1.13.0-rc5 để tôi có thể thay đổi cài đặt "hosts": [] như thế này:Thay đổi Docker "hosts"/"-h" cho Windows trong daemon.json

{ 
    "hosts": [ 
    "tcp://0.0.0.0", 
    "http://0.0.0.0" 
    ] 
} 

Tuy nhiên, sau khi thay đổi các thiết lập bằng cách sử dụng ứng dụng cài đặt tôi đã nhận lỗi này:

Docker daemon failed with message: 
unable to configure the Docker daemon with file C:\ProgramData\docker\config\daemon.json: 
the following directives are specified both as a flag and in the 
configuration file: 
hosts: (from flag: [npipe:////./pipe/docker_engine_windows], 
from file: [tcp://0.0.0.0 http://0.0.0.0]) 

Hình như daemon đã được bắt đầu với -H cờ và cấu hình json không sáp nhập với nó.

Vậy, làm cách nào để chúng tôi có thể thay đổi các cài đặt đó theo tệp json hoặc thay đổi thông số khởi động dockerd?

Trả lời

1

Bạn có một trường hợp tương tự với issue 22339:

This is expected; you cannot specify options both as a flag and in the configuration file (daemon.json).
If you change your DOCKER_OPTS to DOCKER_OPTS="" and restart, then it should work. We explicitly don't "merge" these configurations.

Hoặc thêm trong docker.conf

[Service] 
ExecStart= 
ExecStart=/path/to/dockerd 
# or 
ExecStart=/path/to/dockerd daemon 

Nhưng lập trường chính thức vẫn là:

There's no bug in the systemd configuration, to override defaults in a systemd unit file, you can use a drop-in file, as described in " Custom Docker daemon options ".

Producing an error if both a flag and an option in daemon.json are provided was a design decision when implementing that (in general, flags should always have precedence over configuration files); automatically merging options was not an option, as this would lead to unexpected results (was the intent to override an option, or to add to an option?)

PR 27473 bị từ chối, cho issue 21559.

+0

Xem thêm https://github.com/docker/docker/pull/20410 – VonC

+0

Cảm ơn bạn đã trả lời. Tôi thấy rằng pr/vấn đề là tốt. Tuy nhiên, tôi đang ở trên Windows. Làm thế nào tôi có thể thay đổi anh ta mặc định dockerd prameters vì vậy tôi có thể thêm -H có thay vì trong tập tin? –

+0

Tôi cũng đang tìm kiếm điều này - khá khó chịu rằng Docker cho Windows dường như bắt đầu dịch vụ với cờ -H. Có vẻ như đặt điều này như là một mặc định vào daemon.json sẽ làm việc thay thế? –

Các vấn đề liên quan