-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docker-ce: add uci support #12556
docker-ce: add uci support #12556
Conversation
Otherwise, thanks for the work, sounds like a great idea going forward! |
Sounds great! Now, we can get rid of @feckert And how about the access control? |
@lisaac I have to see how you do it first. |
d850110
to
f5c947a
Compare
I have now added a proof of concept firewall ac handling in the dockerd service with this commit. The advantage we do not need any iptables commands. The firewall handling is abstracted by procd. If we set the following option in the dockerd uci config
then the following rule is added to the firewall by fw3.
Unfortunately, it is not yet clear to me what you @lisaac want to achieve with ac.
The way I see it, this has nothing to do with the configuration interface. Did I get that right? If so is that firewall handling really necessary in docker? /etc/config/network
/etc/config/firewall
|
Without the access control, WAN can easily access the ports exposed by the container using On another hand, sometimes, you would like some ports exposed by containers could be access from WAN. For more details, please see lisaac/blog#7 , https://docs.docker.com/network/iptables/ In order to let those works, I add the access control in luci-app-dockerman.
@feckert I don't think it will work, and maybe we could let dockerman achieve with ac, let docker-ce do his own job |
The docker documentation @lisaac linked leads me to believe that this kind of setup is outside the scope of It could be argued either way really, but since one of the reasons to use OpenWrt is "Security" and being able to access from the WAN by default seems to go against that. I lean slightly in favour of configuring it from Also, if we decide to do AC here, it looks like this PR would close #12358 |
f5c947a
to
4586500
Compare
@G-M0N3Y-2503 thanks for the docker iptables link. That was so not clear to me that the IP packages that are for docker are not handled by the fw3 of openwrt firewall. Then we can forget about the procd (firewall_array)? @lisaac If I see this correctly, would it be better to add the rules for the docker to DOCKER-USER and not do the new DOCKER-MAN chain? |
@feckert Use a custom chain to facilitate maintenance |
4586500
to
2c33d39
Compare
I have update the pullrequest so that on docker stop the related pullrquests for dockerd are removed. |
Hi everybody, My two cents with respect to this PR, with apologies for the length, but there I have been using docker extensively in openwrt for more than 6 months. I am
Or in a docker-compose.yml, instead of doing:
We would do something like:
|
Let me give you a few examples. I currently have 20+ containers running, All those random addresses are a PITA from a security and administration point I first tried adding the bridges to I ended up adding the networks this way:
With this I have a nice view of all the interfaces (real and virtual) on my docker0, lan and the docker bridges are in different zones. Access between It could be much cleaner if we could set the bridges as externally managed With respect to the access control, we could probably change the default |
Last, we could add support for defining macvlan bridges directly in
But you need to set the macvlan bridge yourself:
This can be added as a hotplug script to make it automatic. Again, this could be much nicer if we had a macvlan bridge option in openwrt's For reference, you can see the complete set of docker-compose files I am using What do you think? |
@jmarcet Thanks for your feedback and your thoughts But for the last one:
I think this is already possible. The service netifd could setup this. I have the following uci config in /etc/config/network to setup a macvlan docker setup.
After an reload_config I could start the container and setup the network with the following commands.
|
@feckert Wow, that was fast!
Really interesting. This just needs to be documented then. |
@jmarcet @feckert
We do have macvlan bridge option in it, and if you want, you can use dockerman to add macvlan network, dockerman will add macvlan gateway interface automatically(with the option). Maybe we could edit |
I Imagine we'll only cover the options that are frequently used, at least until someone adds them all or writes something to serialize/deserialize the UCI to the But now I think of it, we should have a way to not use the UCI for advanced configurations. Otherwise, it looks like we agree that |
2c33d39
to
6bd25e9
Compare
That's what I thought too, that we won't get all configuration options into the uci. @G-M0N3Y-2503 I would like to finish this PR to get this in. |
json_add_string "" "$1" | ||
} | ||
|
||
process_config() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense for process_config()
to either return the config file or set DOCKERD_CONF
directly, rather than using symlinks.
if /etc/config/dockerd
doesn't exist DOCKERD_CONF
equals ""
because the daemon will just startup with its defaults and not mislead anyone looking at the process command line.
if alt_config_file
is set in the UCI, DOCKERD_CONF
will equal that if it exists or ""
because it's most likely an error.
otherwise, we set DOCKERD_CONF
to the one the UCI will generate "/tmp/dockerd/daemon.json"
This Implementation looks a little more complicated than it needs to be, perhaps I wasn't clear about what I think is important. I think longterm we want the UCI config to be the default configuration file as it will probably be enough for most users. So we will have to break the previous configuration for this, preferably before a mainline release. I'm leaning towards ripping off the band-aid with this PR, but I'm open to suggestions as to when. So with that, It might be nicer from a maintainers perspective to just have a default If we still want an |
I should also mention that from my point of view it is important that we store the uci generated configuration in tmp. |
hmmm, I think I may not have been clear, I wasn't talking about whether the config should be in In summary:
diff --git a/utils/docker-ce/Makefile b/utils/docker-ce/Makefile
index 8ed184c40..f8b1d13e0 100644
--- a/utils/docker-ce/Makefile
+++ b/utils/docker-ce/Makefile
@@ -124,9 +124,6 @@ define Package/docker-ce/install
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/dockerd.init $(1)/etc/init.d/dockerd
- $(INSTALL_DIR) $(1)/etc/docker
- $(INSTALL_CONF) ./files/daemon.json $(1)/etc/docker/
-
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/etc/config/dockerd $(1)/etc/config/dockerd
diff --git a/utils/docker-ce/files/daemon.json b/utils/docker-ce/files/daemon.json
deleted file mode 100644
index 53c03211f..000000000
--- a/utils/docker-ce/files/daemon.json
+++ /dev/null
@@ -1,4 +0,0 @@
-{
- "data-root": "/opt/docker/",
- "log-level": "warn"
-}
diff --git a/utils/docker-ce/files/dockerd.init b/utils/docker-ce/files/dockerd.init
index c2e5c4dcc..c892c203b 100644
--- a/utils/docker-ce/files/dockerd.init
+++ b/utils/docker-ce/files/dockerd.init
@@ -12,14 +12,18 @@ json_add_array_string() {
process_config() {
local alt_config_file data_root log_level
- [ -f /etc/config/dockerd ] || return 0
-
rm -f "$DOCKERD_CONF"
+
+ [ -f /etc/config/dockerd ] || {
+ # Use the daemon default configuration
+ DOCKERD_CONF=""
+ return 0
+ }
+
config_load 'dockerd'
config_get alt_config_file globals alt_config_file
[ -n "$alt_config_file" ] && [ -f "$alt_config_file" ] && {
- rm -f "$DOCKERD_CONF"
ln -s "$alt_config_file" "$DOCKERD_CONF"
return 0
}
diff --git a/utils/docker-ce/files/etc/config/dockerd b/utils/docker-ce/files/etc/config/dockerd
index f49860c6a..b89d5e4bf 100644
--- a/utils/docker-ce/files/etc/config/dockerd
+++ b/utils/docker-ce/files/etc/config/dockerd
@@ -1,7 +1,6 @@
-
config globals 'globals'
- option alt_config_file "/etc/daemon.json"
-# option data_root "/opt/docker/"
-# option log_level "warn"
+# option alt_config_file "/etc/docker/daemon.json"
+ option data_root "/opt/docker/"
+ option log_level "warn"
# list registry_mirror "https://<my-docker-mirror-host>"
# list registry_mirror "https://hub.docker.com" |
6bd25e9
to
d6e8521
Compare
I understand now what you mean. I agree with you that we use the uci variant as default. I added your suggestion, so we return if no uci config for docker is found, and use the docker config default location. The one thing I did not change is the installation of the daemon.json file you suggested. @G-M0N3Y-2503 please check my changes. If I get a thumb up I will merge this. |
It isn't necessary exactly, just that the same config can now be achieved by the default or empty But this PR looks good to me either way. |
Signed-off-by: Florian Eckert <[email protected]>
Signed-off-by: Florian Eckert <[email protected]>
Until now, the firewall rules from the dockerd were preserved after the service was stopped. This is not nice. With this change the firewall rules created by dockerd will be deleted when the dockerd service is stopped. Signed-off-by: Florian Eckert <[email protected]>
Signed-off-by: Florian Eckert <[email protected]>
d6e8521
to
7765f5c
Compare
@G-M0N3Y-2503 Thanks for your input and review 👍 |
@feckert @G-M0N3Y-2503 In order to allow manually configures |
I don't think I understand @lisaac... Do you mean that we should have the UCI override parts of the daemon.json? |
Yes, exactly.
Yes, it works, just different way. |
Maintainer: @G-M0N3Y-2503
Compile tested: only script changes
Run tested: x86_64, APU3, OpenWrt master
Description:
Recently we also have the application luci-app-dockerman in the LuCI. In this app we have also an service which reads the configuration from /etc/docker/daemon.json and compares this against his own uci configuration in /etc/config/dockerman. To reconcile configuration differences a script is used, so that everything works again.
To simplify things I think it is better to move the uci into the docker-ce package. So that we have a clear responsibility.
@lisaac To get everything working again we have to make some changes to the luci-app-dockerman as well.
Since docker's configuration options are very large, I don't think we can display all configuration options here. But I guess it doesn't hurt that we can configure at least a few things.