Docker on 11.0

Status
Not open for further replies.

ArgaWoW

Patron
Joined
Jul 4, 2015
Messages
444
  1. Download CentOS 7 minimal install ISO onto a share on NAS
  2. Create a VM with a small-ish OS drive zvol and assign it as disk device for the VM (Both NIC and disk devices can use VirtIO drivers since it's fully support)
  3. Add cdrom device and point to the ISO
  4. Boot up and perform install, leave disk partition to auto if you don't care (or do it manually if you know how to for UEFI bootloader)
  5. Configure IP, hostname etc
  6. Finish install and restart and remove the cdrom device
  7. Turn off wait to boot for VNC device as I believe this makes the VM wait until you VNC in on subsequent bootup or restart
  8. Once booted, log in as root
  9. yum -y update
  10. Do Docker CE install (https://store.docker.com/editions/community/docker-ce-server-centos?tab=description)
  11. Install NFS client (https://www.howtoforge.com/nfs-server-and-client-on-centos-7, look for NFS client section)
  12. Create NFS share on NAS for container volumes and mount it in the VM (I put it under /mnt/docker), be sure to edit /etc/fstab so the mount is persistent (map all user to root/wheel for the share because Docker will try to chown the share and if it can't it won't start)
  13. docker run with -v flag to point volumes in container to the path you mounted the NFS share
  14. Profit??
This way if and when Docker becomes fully baked-in, the volume share can be reused.
This worked for me. Thanks a lot.
Plex, plexpy, pyload and teamspeak now running on Dockers within freenas 11

Great[emoji106]

Gesendet von meinem SM-G955F mit Tapatalk
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Sure! Disclaimer: I'm a docker newbie. Totally green!

1) Create a VM and install Ubuntu. You already did that. Yay! :)
2) In FreeNAS, set up a datastore to share via NFS. I chose to create it with "All Directories" checked, because I want to be able to mount subdirectories individually. Make sure the "NFS" service is started in FreeNAS.
3) Mount that share in your Ubuntu VM. I'm old school (no autofs for me!), so I edited /etc/fstab and added:
Code:
192.168.1.10:/mnt/Pool/MediaFiles /home/Media  nfs rsize=8192,wsize=8192,timeo=14,intr

192.168.1.10 is the FreeNAS IP, /mnt/Pool/MediaFiles is the FreeNAS path, /home/Media is where I want to mount it in Ubuntu.
mount -a or mount /home/Media should mount that share - it gets automatically mounted at reboot due to the fstab entry. Also, make sure that rpc.statd and rpcbind are running on Ubuntu.

4) apt install docker.io (for some reason I used docker.io and not just docker. I assume I read somewhere that's either important or easy) If it doesn't run, start it with systemctl start docker.
5) I really like "portainer" from "portainer.io" to handle my containers. It doesn't do *everything* that you can do from the command line, but it does enough for me ;)
I installed/ran that via
Code:
docker run  \
  --name=portainer  \
  --restart=unless-stopped  \
  -d -p 9000:9000  \
  -v /var/run/docker.sock:/var/run/docker.sock \
  portainer/portainer

It REALLY makes sense to put those commands into a file and execute that file sh FILE :)
Then open your browser and go to "ip-of-ubuntu:9000"

6) Head on over to "linuxserver.io", go to "docker images". Click on whatever catches your eye, for instance "sabnzbd" :) They give you step-by-step instructions. I copy/paste the "usage" part into a file and edit it in there so I remember the settings. Make sure you edit the various settings, especially take care of the "-v" directory mappings. Basically you map an Ubuntu path to an internal docker-container path. You should NOT rename the container paths, only mess with the left part ;)

I add an option near the top " --restart=unless-stopped" if I want that container to start up automatically (unless if I stopped it!)

Now, the neat thing is: If you screw up with the pathnames, timezone setting, or anything when you "created" your container - let's say you're sticking your movies into the wrong folder, you have to remove and recreate the container (there may be better ways, but hey. I said I was new!)
To do that: Either remove the container in portainer or say:
docker rm <whatever-you-named-the-container in the --name option> For instance docker rm sabnzbd or docker rm portainer.
Then edit the file where you set everything up (see above, told you it was a good idea) and re-run that file (or the docker run/create command)

The neat thing is, unless you messed up the "ubuntu=path:/config" setting for your container, all the settings are still there! I've probably re-done "sonarr" half a dozen times because of my inexperience with the path mappings (where do the TV shows go? What's the path to where sab saves the downloads again?) but never had to set up Sonarr from scratch - just tweak it.

I hope that helps to get you started - and I hope I didn't miss anything important!

Frank

Edit: PS! I ran all the commands as root. sudo -i is my friend!

Been playing with this and other ways of getting Docker containers up... Settled on setting up an Ubuntu-16.04.2 VM, and this approach. Works nicely.

This post tells you how to fix Ubuntu booting on FreeNAS 11-RC :
https://forums.freenas.org/index.php?threads/how-to-how-to-boot-linux-vms-using-uefi.54039/

...

Now, since the Docker containers all start up on reboot, I wanted to have the Ubuntu VM nicely shutdown when you hit Stop in FreeNAS...


sudo nano /etc/acpi/events/power

then paste this into the file...
Code:
event=button/power (PWR.||PBTN)
action=/sbin/poweroff


then

sudo acpid restart

to restart the acpi daemon.

Now, when you hit stop in FreeNAS, the Unbuntu VM will perform an orderly shutdown

Next, edit the devices on the VM, and make sure that you have the VNC "Wait for boot" disabled.

Now you can start/stop your Dockers to your hearts content with the FreeNAS start/stop button on the host VM.

Joy.
 
Last edited:

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
PS! I ran all the commands as root. sudo -i is my friend!

I've continued playing around with Docker. This might help

https://docs.docker.com/engine/inst...postinstall/#manage-docker-as-a-non-root-user

As your docker user (not root)

sudo groupadd docker (might be unnecessary)
sudo usermod -aG docker $USER (need to logout to take effect)

This will add your user to the docker group, which means that you won't need to use sudo when operating on docker. Of course, that makes it easier to shoot yourself, but then again, sudo -i is even worse.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Now, since the Docker containers all start up on reboot, I wanted to have the Ubuntu VM nicely shutdown when you hit Stop in FreeNAS...

Is this necessary? Have you observed the behaviour of your running VM over VNC/ssh when you simply shutdown your FreeNAS host without first stopping the VM?

AFAIK, an Ubuntu VM shuts down in an orderly fashion without the need for extra steps.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Is this necessary? Have you observed the behaviour of your running VM over VNC/ssh when you simply shutdown your FreeNAS host without first stopping the VM?

Yes, it pulls the power, because the VM ignores the powerbutton.

I tested this with ssh, vnc at login and vnc at desktop.

AFAIK, an Ubuntu VM shuts down in an orderly fashion without the need for extra steps.

Yes, it never stops. Unbuntu Minimal 16.04.2 by default has 'interactive' for its handling of power-button, which means the GUI puts up a pretty window offering to time delay, shutdown, restart or cancel.

If you don't have the VNC device, and thus no graphics device, then perhaps you don't get that.

And that means the VM will never stop without user interaction over VNC.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Is this an Ubuntu server install? In any case, according to thread below,

"when the host is shutting down it will send a SIGTERM to all running processes
and translating this into an ACPI poweroff event for the guest allows
it to shutdown cleanly.
"

https://lists.freebsd.org/pipermail/freebsd-virtualization/2016-April/004360.html

I've not yet seen the behaviour you describe.

ubuntu-16.04.2-desktop-amd64.iso

Not server.

BTW, /sbin/poweroff sends SIGTERM to all running processes

Essentially, you shutdown, FreeNAS, it sends SIGTERM to all running processes, that sends a power-button ACPI event to the VM instance. The UbuntuVM catches the ACPI power-button event, and runs /sbin/poweroff, which sends a SIGTERM to all running processes in the UbuntuVM.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Why use a desktop VM just to run docker?

I have a need for an Ubuntu VM for more than just docker. This way I only have to dedicate so many resources to unbuntu vms.

Maybe I should've used server. Does it have the GUI?
 
Last edited:

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
The clue is in the name, Ubuntu server is text mode CLI by default. Obviously, I don't know your precise use case, but server and GUI don't normally go together, unless you're talking about tools for remote admin - webmin, cockpit, etc.
 

SavageAUS

Patron
Joined
Jul 9, 2016
Messages
418
Personally I use a CentOS minimal vm for docker and have a Ubuntu 17.04 vm.

Sent from my SM-G930F using Tapatalk
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
The clue is in the name, Ubuntu server is text mode CLI by default. Obviously, I don't know your precise use case, but server and GUI don't normally go together, unless you're talking about tools for remote admin - webmin, cockpit, etc.

That's what I thought. My specific requirement is to be able to run karma tests, which are browser based integration/unit tests. There are probably other things which I haven't worked out yet. I'll probably add a Windows 10 VM for a similar reason.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Personally I use a CentOS minimal vm for docker and have a Ubuntu 17.04 vm.

Sent from my SM-G930F using Tapatalk

I've personally used debian netinstall, but each to his own. The more adventurous have used rancheros/server, or even boot2docker.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Personally I use a CentOS minimal vm for docker and have a Ubuntu 17.04 vm.

Sent from my SM-G930F using Tapatalk

And it works nicely that way. I had RHEL flashbacks when I tested CentOS minimal for docker ;)
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
I've personally used debian netinstall, but each to his own. The more adventurous have used rancheros/server, or even boot2docker.

I also tried rancheros, but you need grub-bhyve to get it to boot, and FreeNAS' VM tab doesn't support that yet.

Did get it working very nicely and cleanly via iohyve. But its designed to use a disk as a persistence store, rather than an NFS layer, so I don't think its the right approach for FreeNAS.

Didn't bother with boot2docker.
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
I also tried rancheros, but you need grub-bhyve to get it to boot, and FreeNAS' VM tab doesn't support that yet.

Did get it working very nicely and cleanly via iohyve. But its designed to use a disk as a persistence store, rather than an NFS layer, so I don't think its the right approach for FreeNAS.

Didn't bother with boot2docker.

True, but NFS storage is one of the choices you can make in rancheros and it looks like FreeNAS have picked it as their docker platform: https://bugs.freenas.org/issues/23357

It remains to be seen how that works out.
 

Stux

MVP
Joined
Jun 2, 2016
Messages
4,367
Speaking of NFS,

So, I've been looking into what's the *best* way to get NFS into Docker...

There is a very young nfs storage driver for Docker, but that would obviate other drivers. So, as people have already been doing, the best approach is probably just to use an NFS mount.

But, a better approach is may be to use the secret NFS support built into docker ;)

https://www.immense.ly/2016/10/18/on-docker-storage-and-nfs/

And if you're going to use NFS, then it would be better if NFS supported sparse files... as there's lots of sparse file stuff in Docker

https://serverfault.com/questions/731632/does-nfs-and-smb-support-sparse-files

It seems like it would make sense to use nfsv4.2+ when using NFS to a docker-host from FreeNAS.

So, what version of NFSv4 does FreeNAS-11 support?
 
Last edited:

SavageAUS

Patron
Joined
Jul 9, 2016
Messages
418
And it works nicely that way. I had RHEL flashbacks when I tested CentOS minimal for docker ;)
Same same. But it works.

Sent from my SM-G930F using Tapatalk
 

Osiris

Contributor
Joined
Aug 15, 2013
Messages
148
I have/had docker working in a ubuntu server 17.04 vm with docker 17/13.x (bizarre versioning).
I have however just done some kind of project where I've setup Redhat's Openshift with Kubernetes on 2 CentOS7 vms (on different FreeNAS boxes).
Right now I'm evaluating whether I'm going for a mixed setup, as you can still approach docker directly while under Openshift.
I will probably check out Docker Swarm.

Currently I have tons of issues concerning rwx rights to deploy stuff in Openshift.
Certain containers (like linuxserver/sabnzbd) work with specific uids ...

On the ubuntu vm with just docker, this was kinda clear.
I created a user with uid/gid 1001/1001 on the freenas host, the same on the ubuntu server vm, then a script that mounts shares (both cifs & nfs, from different nasses) to the vm.
Docker on ubuntu looks as these mounts as native & I NEVER had issues while passing these same uid/gid to the container.

On the Ubuntu server vm, I'm on an oldschool approach atm, giving the containers ip addresses in my lan.
I know, I'm killing docker functionality.
Code:
#!/bin/sh
docker create --name="sabnzbd" \
		-v /mnt/docker-volumes-nfs/sabnzbd/config:/config \
		-v /mnt/seth/downloads/:/downloads \
		-e PGID=1001 \
		-e PUID=1001 \
		-e TZ=Europe/Brussels \
		-p 8080:8080 \
		-p 9090:9090 \
		--restart=always \
		--ip 10.10.35.5 \
		--net docker1 \
		linuxserver/sabnzbd

docker container start sabnzbd
Oh and the network
Code:
#!/bin/sh
docker network create -d ipvlan -o ipvlan_mode=l2 -o parent=enp0s3 --subnet 10.10.0.0/16 --gateway=10.10.0.99 docker1
docker network inspect docker1
And as startup script for docker I'm adding a nic
Code:
#!/bin/sh
/bin/ip tuntap add dev eth0 mode tap
/bin/ip addr add 10.10.32.12/16 broadcast 10.10.255.255 dev eth0
/bin/ip link set eth0 up
/sbin/brctl addif docker1 eth0 2>/dev/null
/mnt/scripts/ub_smbmount.sh
/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --experimental
##--insecure-registry 172.30.0.0/16
 
Last edited:

tanik1

Contributor
Joined
Mar 31, 2013
Messages
163
How come corral have dockers and containers and 11 stopped? it makes it so hard to transition from one version to the next version. when I upgraded to corral i had to learn a lil bit about dockers and created my dockers. Now I upgraded to 11 and all the dockers are gone. And back to the jails setup style. Will 11 use dockers again? or when 12 comes out its going to use dockers again?>
 
Status
Not open for further replies.
Top