4f9db655ed
When mapping a port with the userland-proxy enabled, the daemon would perform an "exec.LookPath" for every mapped port (which, in case of a range of ports, would be for every port in the range). This was both inefficient (looking up the binary for each port), inconsistent (when running in rootless-mode, the binary was looked-up once), as well as inconvenient, because a missing binary, or a mis-configureed userland-proxy-path would not be detected daeemon startup, and not produce an error until starting the container; docker run -d -P nginx:alpine 4f7b6589a1680f883d98d03db12203973387f9061e7a963331776170e4414194 docker: Error response from daemon: driver failed programming external connectivity on endpoint romantic_wiles (7cfdc361821f75cbc665564cf49856cf216a5b09046d3c22d5b9988836ee088d): fork/exec docker-proxy: no such file or directory. However, the container would still be created (but invalid); docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 869f41d7e94f nginx:alpine "/docker-entrypoint.…" 10 seconds ago Created romantic_wiles This patch changes how the userland-proxy is configured; - The path of the userland-proxy is now looked up / configured at daemon startup; this is similar to how the proxy is configured in rootless-mode. - A warning is logged when failing to lookup the binary. - If the daemon is configured with "userland-proxy" enabled, an error is produced, and the daemon will refuse to start. - The "proxyPath" argument for newProxyCommand() (in libnetwork/portmapper) is now required to be set. It no longer looks up the executable, and produces an error if no path was provided. While this change was not required, it makes the daemon config the canonical source of truth, instead of logic spread accross multiplee locations. Some of this logic is a change of behavior, but these changes were made with the assumption that we don't want to support; - installing the userland proxy _after_ the daemon was started - moving the userland proxy (or installing a proxy with a higher preference in PATH) With this patch: Validating the config produces an error if the binary is not found: dockerd --validate WARN[2023-12-29T11:36:39.748699591Z] failed to lookup default userland-proxy binary error="exec: \"docker-proxy\": executable file not found in $PATH" userland-proxy is enabled, but userland-proxy-path is not set Disabling userland-proxy prints a warning, but validates as "OK": dockerd --userland-proxy=false --validate WARN[2023-12-29T11:38:30.752523879Z] ffailed to lookup default userland-proxy binary error="exec: \"docker-proxy\": executable file not found in $PATH" configuration OK Speficying a non-absolute path produces an error: dockerd --userland-proxy-path=docker-proxy --validate invalid userland-proxy-path: must be an absolute path: docker-proxy Befor this patch, we would not validate this path, which would allow the daemon to start, but fail to map a port; docker run -d -P nginx:alpine 4f7b6589a1680f883d98d03db12203973387f9061e7a963331776170e4414194 docker: Error response from daemon: driver failed programming external connectivity on endpoint romantic_wiles (7cfdc361821f75cbc665564cf49856cf216a5b09046d3c22d5b9988836ee088d): fork/exec docker-proxy: no such file or directory. Specifying an invalid userland-proxy-path produces an error as well: dockerd --userland-proxy-path=/usr/local/bin/no-such-binary --validate userland-proxy-path is invalid: stat /usr/local/bin/no-such-binary: no such file or directory mkdir -p /usr/local/bin/not-a-file dockerd --userland-proxy-path=/usr/local/bin/not-a-file --validate userland-proxy-path is invalid: exec: "/usr/local/bin/not-a-file": is a directory touch /usr/local/bin/not-an-executable dockerd --userland-proxy-path=/usr/local/bin/not-an-executable --validate userland-proxy-path is invalid: exec: "/usr/local/bin/not-an-executable": permission denied Same when using the daemon.json config-file; echo '{"userland-proxy-path":"no-such-binary"}' > /etc/docker/daemon.json dockerd --validate unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid userland-proxy-path: must be an absolute path: no-such-binary dockerd --userland-proxy-path=hello --validate unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: userland-proxy-path: (from flag: hello, from file: /usr/local/bin/docker-proxy) Signed-off-by: Sebastiaan van Stijn <github@gone.nl> |
||
---|---|---|
.. | ||
checker | ||
cli | ||
daemon | ||
environment | ||
fixtures | ||
requirement | ||
testdata | ||
benchmark_test.go | ||
check_test.go | ||
daemon_swarm_hack_test.go | ||
docker_api_attach_test.go | ||
docker_api_build_test.go | ||
docker_api_build_windows_test.go | ||
docker_api_containers_test.go | ||
docker_api_containers_unix_test.go | ||
docker_api_containers_windows_test.go | ||
docker_api_exec_resize_test.go | ||
docker_api_exec_test.go | ||
docker_api_images_test.go | ||
docker_api_inspect_test.go | ||
docker_api_logs_test.go | ||
docker_api_network_test.go | ||
docker_api_stats_test.go | ||
docker_api_swarm_node_test.go | ||
docker_api_swarm_service_test.go | ||
docker_api_swarm_test.go | ||
docker_api_test.go | ||
docker_cli_attach_test.go | ||
docker_cli_attach_unix_test.go | ||
docker_cli_build_test.go | ||
docker_cli_build_unix_test.go | ||
docker_cli_by_digest_test.go | ||
docker_cli_commit_test.go | ||
docker_cli_cp_from_container_test.go | ||
docker_cli_cp_test.go | ||
docker_cli_cp_to_container_test.go | ||
docker_cli_cp_to_container_unix_test.go | ||
docker_cli_cp_utils_test.go | ||
docker_cli_create_test.go | ||
docker_cli_daemon_plugins_test.go | ||
docker_cli_daemon_test.go | ||
docker_cli_events_test.go | ||
docker_cli_events_unix_test.go | ||
docker_cli_exec_test.go | ||
docker_cli_exec_unix_test.go | ||
docker_cli_external_volume_driver_test.go | ||
docker_cli_health_test.go | ||
docker_cli_history_test.go | ||
docker_cli_images_test.go | ||
docker_cli_import_test.go | ||
docker_cli_info_test.go | ||
docker_cli_info_unix_test.go | ||
docker_cli_inspect_test.go | ||
docker_cli_links_test.go | ||
docker_cli_login_test.go | ||
docker_cli_logout_test.go | ||
docker_cli_logs_test.go | ||
docker_cli_netmode_test.go | ||
docker_cli_network_test.go | ||
docker_cli_network_unix_test.go | ||
docker_cli_plugins_logdriver_test.go | ||
docker_cli_plugins_test.go | ||
docker_cli_port_test.go | ||
docker_cli_proxy_test.go | ||
docker_cli_prune_test.go | ||
docker_cli_prune_unix_test.go | ||
docker_cli_ps_test.go | ||
docker_cli_pull_local_test.go | ||
docker_cli_pull_test.go | ||
docker_cli_push_test.go | ||
docker_cli_registry_user_agent_test.go | ||
docker_cli_restart_test.go | ||
docker_cli_rmi_test.go | ||
docker_cli_run_test.go | ||
docker_cli_run_unix_test.go | ||
docker_cli_save_load_test.go | ||
docker_cli_save_load_unix_test.go | ||
docker_cli_search_test.go | ||
docker_cli_service_create_test.go | ||
docker_cli_service_health_test.go | ||
docker_cli_service_logs_test.go | ||
docker_cli_service_scale_test.go | ||
docker_cli_sni_test.go | ||
docker_cli_start_test.go | ||
docker_cli_stats_test.go | ||
docker_cli_swarm_test.go | ||
docker_cli_swarm_unix_test.go | ||
docker_cli_top_test.go | ||
docker_cli_update_test.go | ||
docker_cli_update_unix_test.go | ||
docker_cli_userns_test.go | ||
docker_cli_v2_only_test.go | ||
docker_cli_volume_test.go | ||
docker_deprecated_api_v124_test.go | ||
docker_deprecated_api_v124_unix_test.go | ||
docker_hub_pull_suite_test.go | ||
docker_utils_test.go | ||
events_utils_test.go | ||
fixtures_linux_daemon_test.go | ||
requirements_test.go | ||
requirements_unix_test.go | ||
requirements_windows_test.go | ||
test_vars_test.go | ||
test_vars_unix_test.go | ||
test_vars_windows_test.go | ||
utils_test.go | ||
utils_unix_test.go | ||
utils_windows_test.go |