Docker configuration

Hello,

After updating to TOS 6.0 I’m eager to try out docker however I’m reluctant to start deploying containers as the Docker Root Dir is set to /opt/docker.

Docker configuration page is empty however and remains so after reboot and docker re-installation.

Is it possible to move it to /srv/docker so that created containers and volumes do not cause excessive read/writes to emmc?

1 Like

Yes, but I can’t give you any pointers through luci. I did it a few months ago after moving to HBL on TO6. Just follow the docker documentation using ssh

Edit: PS: An other UI way could be portrainer but I haven’t tested it

I will be trying out Portainer once I figure out how to move the docker root dir.

Do you happen to remember if the way you moved it was with a symlink?

Sorry I don’t but it seems that it can be changed from luci
Refer here

Install Docker Community Edition

install docker-ce package for the commandline tools
install luci-app-dockerman package to get a control panel for docker containers in Luci

the default folder for docker in the dockerman luci interface is /opt/docker so you want to mount your storage at /opt or change the folder in Docker –> Overview –> Docker Root Dir and then restart the whole device, or the dockerd service.

I actually read that documentation but it was of no use.

My storage is already mounted at /srv and will break a lot of things if I remount it at /opt.

Also Docker > Overview does not allow changing the Docker Root Dir. That’s why I mentioned that Docker > Configuration is empty in the OP.

Anw thanks for taking the time. I will investigate this further tomorrow as it’s getting late here now.

Ah, what about symlink? Couldn’t it help?

You could try this
or you could try with the daemon.json as reported below

I see some issues reported here with symlinks

Edit: After changing your root dir, you might find this handy for auto cleaning docker logs

I didn’t get around to it yet but from lampra’s reply below yours it appear some issues may arise.

Thanks for this! I will try it tomorrow and report back.

BTW how did you manage to install Luci module for Docker, please?

When I am trying to install it I am getting this error:

Collected errors:
 * check_data_file_clashes: Package libwebsockets-full wants to install file /usr/lib/libwebsockets.so
	But that file is already provided by package  * libwebsockets-openssl
 * check_data_file_clashes: Package libwebsockets-full wants to install file /usr/lib/libwebsockets.so.14
	But that file is already provided by package  * libwebsockets-openssl
 * opkg_install_cmd: Cannot install package luci-app-dockerman.

And as I found this topic, there is hard dependency on libwebsockets-openssl by reforis.

I just installed it normally through the LuCI software page without errors. Try selecting the Overwrite existing files checkbox when you install it.

2 Likes

Are you on the stable branch HBS? I have the same issue, but I didn’t upgrade to the stable branch yet.

Yes, I am on stable branch. But as @makros suggested, forcing to overwrite existing files during installation helped and even reForis is working fine after that.

Perfect, thank you, I wasn’t sure if it won’t break reForis and was afraid to try that on my own :wink:

I just tried this and unfortunately it didn’t work

Based on the advice in this link posted by @lampra I did some investigating and found a workaround until a proper solution is presented by someone more knowledgeable.

In that link it is suggested to modify /etc/docker/daemon.json so that the graph key points to the new docker root path. Taking that information I found that daemon.json is created in /tmp/docker by /etc/init.d/dockerd every time the service is started.

The solution then is to modify /etc/init.d/dockerd and change the line:
config_get data_root globals data_root "/opt/docker/"
to
config_get data_root globals data_root "/path/to/new/docker/root/"

I have to point out that I had a portainer container setup before I did the switch and the container wouldn’t start after I copied the contents of /opt/docker to /srv/docker. I don’t recall the full error but it said something about a symlink to /opt/docker.

After deleting both the container and the volume and creating new ones it worked without issue.

This workaround is very likely to break with new updates of dockerd package and will have to be re-implemented. Whether that is to happen without data loss is anyone’s guess.

1 Like

Based on your solution for dockerman here is what I can see in my dockerman configuration page. Don’t you have this configuration page? The root dir is editable.
docker

1 Like

So finally I see where I have changed the root dir, it is at /etc/config/dockerd
option data_root '/mnt/cloud/docker

No my docker configuration page is empty and remains so even after completely removing and re-installing dockerman.

I checked /etc/config/dockerd and it was empty for some reason. So I uninstalled dockerman, dockerd, and docker and reinstalled them again. I got an error saying that /etc/config/dockerd was different than the packaged one and the new one is at /etc/config/dockerd-opkg.

I deleted the dockerd file and renamed dockerd-opkg to dockerd and restarted the dockerd service.

Dockerman configuration page is properly populated now and I can change the docker root directory.

Thank you.