# Docker isn't running on FreeBSD



## Aruns (May 14, 2020)

Hi All, I have been debugging an issue on FreeBSD 11.3 which is mentioned here;
root@freebsd_DCC:~ # docker start hell0-world
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

I have followed the guidelines given here https://wiki.freebsd.org/Docker#zroot. Docker installed successfully, But it isn't running. 
If someone got it working, please post a fix.


----------



## wolffnx (May 14, 2020)

I'dont think that Docker runs on FreeBSD...just dont


----------



## Stazer (May 14, 2020)

There is an alternative of docker for FreeBSD called Bastille. Docker does not run properly with FreeBSD, since it requires some linux-only features.


----------



## drhowarddrfine (May 14, 2020)

There is an alternative of docker for FreeBSD called jail(). Jail runs great on FreeBSD and doesn't require any linux-only features.


----------



## zirias@ (May 14, 2020)

Bastille might not be an alternative for people wanting "Docker" because they want to use stuff building upon Docker or they're just interested in using existing containers in Docker format. If this matches your usecase, just use Linux.

Jails probably aren't an "alternative" to Docker, but might be, depending on the usecase. A jail is just the technical implementation of a "container". Jails are *much* older than Docker, are robust, well tested and reasonably secure and definitely one of the better solutions in that area. Bastille builds upon these jails to add "Docker-like" management.

Therefore, if you're after some management tooling that is somewhat similar to Docker, give Bastille a go. If all you want is an isolated environment, use plain jails and be happy to have something that's likely to provide better security than Docker.


----------



## SirDice (May 14, 2020)

Aruns said:


> I have followed the guidelines given here https://wiki.freebsd.org/Docker#zroot.


Did you miss that big fat warning at the top of that document?



> Docker's currently broken. We are working on a current, executable version. Help is welcome. Current status: https://reviews.freebsd.org/D21570


----------



## sadaszewski (May 19, 2020)

Please try out https://github.com/sadaszewski/focker/ . If pulling ready-made images is not your priority and you would rather just like to have a reliable image building tool with support for layers (which make it easier to do the development / debugging cycle as you don't have to re-build from scratch, just from the last layer), docker-compose style configuration orchestration, volumes and pretty much all the other great abstractions of Docker APART FROM the registry, you should like Focker.


----------



## Aruns (Jun 9, 2020)

sadaszewski said:


> Please try out https://github.com/sadaszewski/focker/ . If pulling ready-made images is not your priority and you would rather just like to have a reliable image building tool with support for layers (which make it easier to do the development / debugging cycle as you don't have to re-build from scratch, just from the last layer), docker-compose style configuration orchestration, volumes and pretty much all the other great abstractions of Docker APART FROM the registry, you should like Focker.


I tried to work this out. 
After, 
*Installing the Python package from GitHub *

The layout has created like this. 

/focker
/focker/images

Jails and Volumes have not created.


----------



## sadaszewski (Jun 9, 2020)

Aruns said:


> I tried to work this out.
> After,
> *Installing the Python package from GitHub *
> 
> ...



Hi Aruns, This sounds very strange. The code responsible for creating the initial layout looks like this:


```
def zfs_init():
    poolname = zfs_poolname()
    print('poolname:', poolname)
    for path in ['/focker', '/focker/images', '/focker/volumes', '/focker/jails']:
        if not os.path.exists(path):
            os.mkdir(path)
    os.chmod('/focker', 0o600)
    if not zfs_exists(poolname + '/focker'):
        zfs_run(['zfs', 'create', '-o', 'canmount=off', '-o', 'mountpoint=/focker', poolname + '/focker'])
    if not zfs_exists(poolname + '/focker/images'):
        zfs_run(['zfs', 'create', '-o', 'canmount=off', poolname + '/focker/images'])
    if not zfs_exists(poolname + '/focker/volumes'):
        zfs_run(['zfs', 'create', '-o', 'canmount=off', poolname + '/focker/volumes'])
    if not zfs_exists(poolname + '/focker/jails'):
        zfs_run(['zfs', 'create', '-o', 'canmount=off', poolname + '/focker/jails'])
```

and it is executed at the very beginning, every time you run any focker command. All those calls either are not executed because the required directories/datasets already exist OR they raise an exception if they fail. It is virtually impossible to just silently "not create /focker/volumes and /focker/jails". Have you received any error message? What is the output of `zfs list` and `find /focker`?


----------



## diego (Jul 4, 2020)

Docker has been one my big challenges for migrating from Linux to FreeBSD due to my job. I have tried different ways trying to run Docker in FreeBSD but its really unstable.

my current solution

```
1) Run Docker over a Virtual Machine
2) Use Virtualbox as hypervisor
3) Install docker-machine (including scripts bash-completion)
4) Up and running
```
FYI: Even MacOS and Windows10 needs a VM to run docker on it !! (It names is "LinuxKit VM", mor information in this link)








						Announcing LinuxKit: A Toolkit for building Secure, Lean and Portable Linux Subsystems | Docker
					

Learn from Docker experts to simplify and advance your app development and management with Docker. Stay up to date on Docker events and new version



					www.docker.com


----------



## diego (Jul 4, 2020)

my future solution


```
1) Use native BSD hypervisor bhyve
2) Learning curve ;)
```

To be honest I would rather to learn *"bhyve"* that other alternatives like focker, etc.
Best
Diego


----------



## Mjölnir (Jul 5, 2020)

`pkg search bhyve
pkg rdesc vm-bhyve
pkg install vm-bhyve`
a vagrant "plugin" for bhyve is available, too. And user-friendly GUIs will be follow soon, I hope.


----------



## sadaszewski (Jul 7, 2020)

diego said:


> my future solution
> 
> 
> ```
> ...



If you want to run Docker images (=Linux) why bother with a FreeBSD host in the first place. Focker delivers a native solution and works great.


----------



## diego (Jul 7, 2020)

sadaszewski said:


> Focker delivers a native solution and works great.


I will try "focker" solution and see if  it supports all docker features as images, networks, secrets, configs, swarm, etc.
At the moment I am using docker-machine with virtualbox, and one dedicated VM(debian10-docker-server) for more complex environments.


----------



## sadaszewski (Jul 8, 2020)

diego said:


> I will try "focker" solution and see if  it supports all docker features as images, networks, secrets, configs, swarm, etc.
> At the moment I am using docker-machine with virtualbox, and one dedicated VM(debian10-docker-server) for more complex environments.


Focker currently supports images, volumes, containers and compositions. Network configuration is left to the user. To that end, in the composition files it supports the full range of options available in jail.conf. You could have a VNET-based or cloned loopback-based setup etc. but you have to code it yourself (perhaps in the prebuild/postbuild hooks of a composition?). Swarm, secrets and configs are not implemented. Secrets and configs are basically fancy mounts from the container perspective. I would say they are a bit superfluous. One can achieve analogous functionality using volumes. Swarm is another story and I do not have a good answer to that. Depending on your setup sysutils/nomad or sysutils/ansible could be used to orchestrate Focker containers across multiple machines. At the very least you could use Focker to build images for sysutils/nomad benefiting from the layered build support. If you have a particular software application in mind I would be willing to help you prepare the suitable Focker recipes.


----------



## diego (Jul 8, 2020)

Thanks for the information and let me show my current stack docker deployment in FreeBSD 12.1 

Testing simple docker images

```
1) docker-machine create --driver virtualbox test01
   Base on boot2docker.iso (small VM)
or
2) Deploy a minimal Debian10(docker) on Virtualbox (I created this box using packer )
   If I need to test more features  (its faster)
```

Testing docker swarm cluster

```
1) Deploy a docker Swarm cluster (1 manager + 1 worker) using vagrant on Virtualbox
2) vagrant boxes have been provision using packer too
3) vagrant plugins (networking, host, etc)
```

At the moment I have had no problems with my own "stack solution" (so far so good) but I would like to try  bhyve instead virtualbox  and see in which hypervisor the performance is better

PD: I think that it would be for another new post


----------



## sadaszewski (Jul 8, 2020)

diego said:


> Thanks for the information and let me show my current stack docker deployment in FreeBSD 12.1
> 
> Testing simple docker images
> 
> ...


Ok thanks for sharing your experiments. But which software would you like to actually run in your container(s)?


----------



## diego (Jul 8, 2020)

sadaszewski said:


> Ok thanks for sharing your experiments. But which software would you like to actually run in your container(s)?


Due to my job, I am deploying docker services using terraform in Docker swarms with TLS.
Software: jenkins, gocd, traefik, mongodb, nexus3, portainer,etc
Dockerized apps: written in python3 and java

Is a good bunch of technologies together  (terraform, packer, vagrant, docker, virtualbox) an really easy to create a whole environment from scratch, tested and destroy them in seconds. When the tests are done I am able to deploy them in VMware Sphere, AWS, on-premises, etc.


----------

