Help me set up docker

hi can someone please help me set up docker on my pi3? everytime i tried it i just failed.

What's the operating system that's running on the Pi 3? Is it OpenWRT, or something else?

yes its openwrt. also i need help with expanding the storage for the docker. it only has 100mb ish but i have 32gb sd card

I don't have direct experience of installing Docker on OpenWRT, but I do have a test lab at my disposal so I can give it a go later on. I've installed Docker on both Raspbian and Ubuntu before now.

That should be reasonably straightforward. On another computer, use a tool like GParted or an equivalent to expand the relevant partition in question.

Alternately, if an in-place partition increase is supported, it might be possible to expand the partition size directly within OpenWRT. For example, both fdisk and parted are available as opkg packages, along with several other partition-related packages. (I have not attempted this, so this is only speculation; I always go for the offline partition manipulation approach.)

i will give it a try. thank you for now.

or just create an extra partition, and use as exroot or data.

1 Like

i will try

Some trial-and-error and experimentation later, I don't - yet - have a fully-usable instance of docker, but I've got... something. I'll keep tinkering. You might be able to build on what I've done and beat me to the answer.

You may find Getting Docker to work First Try useful.

For this test I'm using OpenWRT 22.03.5 x86_64 ext4 inside VMware Workstation 17 Pro, with the disk expanded to 32GB and partition 2 expanded to fill the rest of the disk. That is not to suggest that this is the "correct" or "best" method, merely that it's what I did.

root@vm-openwrt:~# df -h
Filesystem                Size      Used Available Use% Mounted on
/dev/root                31.6G     18.6M     31.5G   0% /
tmpfs                   479.4M     60.0K    479.3M   0% /tmp
/dev/sda1                15.7M      5.2M     10.2M  34% /boot
/dev/sda1                15.7M      5.2M     10.2M  34% /boot
tmpfs                   512.0K         0    512.0K   0% /dev

First up, the instructions at https://openwrt.org/docs/guide-user/virtualization/docker_host are possibly incomplete or out-of-date.

There is no docker-ce package any more (if there once was). There is, however, a docker package. But installing both docker and luci-app-dockerman on their own is insufficient, and you end up with this:

In addition, you end up with an empty /etc/config/dockerd file (note the big, fat 0):

root@vm-openwrt:/etc/config# ls -al
drwxr-xr-x    2 root     root          4096 Jul 18 16:51 .
drwxr-xr-x   23 root     root          4096 Sep 27  2021 ..
-rw-------    1 root     root           832 Jul 18 16:47 dhcp
-rw-r--r--    1 root     root             0 Jul 18 16:51 dockerd
-rw-------    1 root     root           134 Apr 27 20:28 dropbear

You also need to install dockerd (and optionally docker-compose if you want to use those features).

I suspect that what once was the package docker-ce installed both the container daemon and the command-line client to manage it, functions which are now provided by the two separate packages docker and dockerd.

Be aware: if you do not remove the empty /etc/config/dockerd first then opkg will refuse to overwrite it, creating a separate /etc/config/dockerd-opkg file instead.

Assuming you have removed /etc/config/dockerd and then installed dockerd, you should end up with this:

root@vm-openwrt:/etc/config# ls -al
drwxr-xr-x    2 root     root          4096 Jul 18 17:07 .
drwxr-xr-x   24 root     root          4096 Jul 18 17:07 ..
-rw-------    1 root     root           851 Jul 18 17:03 dhcp
-rw-------    1 root     root          1550 Jan  3  2023 dockerd
-rw-------    1 root     root           134 Apr 27 20:28 dropbear
root@vm-openwrt:/etc/config# cat dockerd
# The following settings require a restart of docker to take full effect, A reload will only have partial or no effect:
# log_driver
# bip
# blocked_interfaces
# extra_iptables_args
# device

config globals 'globals'
#       option alt_config_file '/etc/docker/daemon.json'
        option data_root '/opt/docker/'
#       option log_driver 'local'
        option log_level 'warn'
        option iptables '1'
#       list hosts 'unix:///var/run/docker.sock'
#       option bip '172.18.0.1/24'
#       option fixed_cidr '172.17.0.0/16'
#       option fixed_cidr_v6 'fc00:1::/80'
#       option ipv6 '1'
#       option ip '::ffff:0.0.0.0'
#       list dns '172.17.0.1'
#       list registry_mirrors 'https://<my-docker-mirror-host>'
#       list registry_mirrors 'https://hub.docker.com'

# Docker doesn't work well out of the box with fw4. This is because Docker relies on a compatibility layer that
# naively translates iptables rules. For the best compatibility replace the following dependencies:
# `firewall4` -> `firewall`
# `iptables-nft` -> `iptables-legacy`
# `ip6tables-nft` -> `ip6tables-legacy`

# Docker undermines the fw3 rules. By default all external source IPs are allowed to connect to the Docker host.
# See https://docs.docker.com/network/iptables/ for more details.

# firewall config changes are only additive i.e firewall will need to be restarted first to clear old changes,
# then docker restarted to load in new changes.
config firewall 'firewall'
        option device 'docker0'
        list blocked_interfaces 'wan'
#       option extra_iptables_args '--match conntrack ! --ctstate RELATED,ESTABLISHED' # allow outbound connections
root@vm-openwrt:/etc/config#
root@vm-openwrt:/etc/config# ls -al /opt/docker
drwx--x---   14 root     root          4096 Jul 18 17:07 .
drwxr-xr-x    4 root     root          4096 Jul 18 17:07 ..
drwx--x--x    4 root     root          4096 Jul 18 17:07 buildkit
drwx--x--x    3 root     root          4096 Jul 18 17:07 containerd
drwx--x---    2 root     root          4096 Jul 18 17:07 containers
drwx------    3 root     root          4096 Jul 18 17:07 image
drwxr-x---    3 root     root          4096 Jul 18 17:07 network
drwx--x---    3 root     root          4096 Jul 18 17:07 overlay2
drwx------    4 root     root          4096 Jul 18 17:07 plugins
drwx------    2 root     root          4096 Jul 18 17:07 runtimes
drwx------    2 root     root          4096 Jul 18 17:07 swarm
drwx------    2 root     root          4096 Jul 18 17:07 tmp
drwx------    2 root     root          4096 Jul 18 17:07 trust
drwx-----x    2 root     root          4096 Jul 18 17:07 volumes
root@vm-openwrt:/etc/config#

However...

There is still more which needs to be done, and it is here that you might beat me to the answer.

Installing docker, dockerd, and luci-app-dockerman still isn't sufficient:

root@vm-openwrt:/etc/config# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
719385e32844: Pull complete
Digest: sha256:926fac19d22aa2d60f1a276b66a20eb765fbeea2db5dbdaafeb456ad8ce81598
Status: Downloaded newer image for hello-world:latest
docker: Error response from daemon: failed to create endpoint competent_mclean on network bridge: adding interface veth6f0fb2f to bridge docker0 failed: could not find bridge docker0: route ip+net: no such network interface.
ERRO[0002] error waiting for container: context canceled
root@vm-openwrt:/etc/config#

Now, I should note here that I did not yet follow the later instructions referenced above, to install any additional virtual network-related packages, so I am not entirely surprised by the particular failure seen here. This is a "progress so far" report, not an "it's broken" report.

I suspect the answer is to find and install the correct packages (and maybe the documentation is correct for this bit), after which docker run hello-world might work...

thank you for this help. i really appreciate it. but from the point you wrote me first time im still trying to expand the root partition on my sd card. i have been trying to resize it for the past 2 days and still cant manage it to do it. i have tried almost everything i think. do you know something that could manage to do it?

Is it an ext4 or squashfs, the latter I assume ?

I, too, struggled to expand the second partition when working with the squashfs image, which is why I gave up and ended up using the ext4 image instead for the test.

You may find that following @frollic's suggestion of extroot might be the quickest and easiest approach.

However, if you are of a mind to try to resize that partition, does either of these threads help?

The extroot guide is here.

If you haven't gotten very far, reinstall using ext4.

1 Like

i think ext4

im just trying to resize it with the 1st thread

Then resizing shouldn't be an issue, especially if you pull the card, and use gparted, or any random Linux dist.

just plugged the card in and started gparted. but i still can resize the partition labeled as boot by few MB. but the rootfs partition can be resized but i havent managed to put it in openwrt to use as storage for packages. i have been stuck at this point for a long time. do you know what to do?

As indicated previously, use the ext4 image instead, or use extroot. Either approach will get you some extra usable space for your containers.

By the way, screenshots may help. There's a reason why "show, don't tell" is a standard mantra.

Don't know the layout of the Pi image, but if there's a boot partition and a rootfs partition, as on x86, it's the latter you want to resize.
The boot partition doesn't need more space.
Nor can it be resized, since the root partition is located right next to it.

and what do i do in openwrt when i resize the partition. i tried mount points but i havent been able to mount it.

There's no error message?
Amazing...