26

I was wondering if it's possible to install and run Docker in a Ubuntu 14.04 USB Live-Disk.

I'm trying it with a 8GB USB, 4 GB for installation and 4 GB for persisted storage, but I keep getting errors when running the containers (no problem in pulling them).

Here is my Docker version:

$ sudo docker version
Client version: 1.6.2
Client API version: 1.18
Go version (client): go1.4.2
Git commit (client): 7c8fca2
OS/Arch (client): linux/amd64
Server version: 1.6.2
Server API version: 1.18
Go version (server): go1.4.2
Git commit (server): 7c8fca2
OS/Arch (server): linux/amd64

And the current error I'm getting when running a docker container is:

[8] System error: mountpoint for cpu not found 

OBS: Sometimes the error is that the cpuset or that the devices were not found.

The kernel of the live-disk that I'm using is:

$ uname -r
3.13.0-32-generic

If the Ubuntu live disk is not the best live-disk to run Docker, are there any other alternatives that have some GUI with it, not just a simple terminal to run docker?

I'm saying this because I'm trying to introduce Docker to my parents, but they don't want to install a linux in their PCs, and so I need some simple graphic interface to write down the Dockerfile, open a browser, etc...


UPDATE

I saw that during the install there was a error when setting up the cgroup-lite dependency initctl: Unknown job: cgroup-lite. Also I read that some ubuntu need to install apparmor so that the docker installation works properly.

So I installed it and reinstalled docker (cgroup-lite installed with no problem then), and now I'm getting this when running the sudo docker -d

INFO[0000] +job serveapi(unix:///var/run/docker.sock)   
INFO[0000] Listening for HTTP on unix (/var/run/docker.sock) 
INFO[0000] +job init_networkdriver()                    
INFO[0000] -job init_networkdriver() = OK (0)           
WARN[0004] Your kernel does not support cgroup swap limit. 
INFO[0004] Loading containers: start.                   
......
INFO[0004] Loading containers: done.                    
INFO[0004] docker daemon: 1.6.2 7c8fca2; execdriver: native-0.2; graphdriver: aufs 
INFO[0004] +job acceptconnections()                     
INFO[0004] -job acceptconnections() = OK (0)            
INFO[0004] Daemon has completed initialization 

And when trying to run a container I receive>

ERRO[0125] HTTP Error: statusCode=500 Cannot start container 90875e79dec37cec41a67aac235b81f0fc17c4e011cd6e5368a4b29336587f5b: 
[8] System error: permission denied

Not sure about the kernel not supporting cgroup, but if so, then is it possible to update the kernel in the livedisk (persisting it?) ?

Arruda
  • 862
  • 1
  • 12
  • 24
  • Have you seen this: https://github.com/docker/docker/issues/7993 ? – Juan Lopes May 15 '15 at 14:08
  • Yep, tried it out but that wasn`t the problem =/ – Arruda May 15 '15 at 23:10
  • Can you check https://github.com/docker/docker/issues/9745#issuecomment-73732245? `sudo apt-get install apparmor` – VonC May 18 '15 at 14:21
  • @VonC already installed the apparmor, the last Update I posted was with the error that I get after I done that. – Arruda May 19 '15 at 15:16
  • 1
    You might also look into a minimal OS that supports docker directly: https://blog.inovex.de/docker-a-comparison-of-minimalistic-operating-systems/ – BraveNewCurrency May 25 '15 at 07:22
  • For what I've seen, this would make necessary to install the GUI libraries (not really a problem), and in the end, the problem seems related to having AUFS on top of a filesystem that is not EXT4 =/ So I would have to make a live disk of this minimal OS and I'm not sure they would fit this AUFS over EXT4 requirement. – Arruda May 25 '15 at 13:35

5 Answers5

18

I've managed to make this work by changing the Docker storage to devicemapper instead of AUFS.

If your system doesn't use Systemd

You just have to change /etc/default/docker to have this in it:

DOCKER_OPTS="--storage-driver=devicemapper"

If your system uses Systemd

See this answer and add --storage-driver=devicemapper at the end of the docker start command.

I've manage to make the containers run ok with this, but I prefer using AUFS.

I realized that the partition was not using aufs by default, but something like caw or cow (can't remember now).

I also tried to make it work using AUFS using the union=aufs flag in grub, but when running the docker daemon I get a FATA[0000] Shutting down daemon due to errors: error intializing graphdriver: backing file system is unsupported for this graph driver, that looks related to https://github.com/docker/docker/issues/7321

I'll leave my answer here, since it is a workaround for this problem, but if anyone manage to make this work using AUFS it would be, in my opinion, a better answer.

Peeyush Kushwaha
  • 3,453
  • 8
  • 35
  • 69
Arruda
  • 862
  • 1
  • 12
  • 24
6

You want to tell the Docker daemon to store the data related to your containers on the persistent storage.

By default the docker daemon put those data into /var/lib/docker. You can change that location with the --graph docker daemon option

Thomasleveil
  • 95,867
  • 15
  • 119
  • 113
  • Actually the root partition in the live disk is already persistent (I'm booting it setting the `persistent` flag in grub). I know that because any change in /var/lib/docker gets persisted (if i pull a image it's stay there when I reboot, or if I change an opt in `/etc/default/docker` it also persist. – Arruda May 24 '15 at 18:58
3

I had a similar problem on Debian Live system. For the latest docker, changing the /etc/default/docker is not making any change.

Appending --storage-driver=vfs to the /lib/systemd/system/docker.service just helped for me:

...
ExecStart=/usr/bin/dockerd --storage-driver=vfs -H fd://
...

(vfs may have poor performance, but aufs, overlay2 and devicemapper were not working properly for me.)

igrek51
  • 177
  • 1
  • 9
3

A simpler modern approach

The following doesn't work in Ubuntu 14.04, but it does work in 20.04, 18.04, and 16.04.

Prerequisite: install Docker on the LiveUSB

If you haven't already installed Docker, start a terminal and paste the following commands.

# docker.io is in the "universe" repository, so add it.
sudo add-apt-repository universe

# Only necessary in 16.04, but doesn't hurt anything.
sudo apt-get update

# Install Ubuntu's Docker package
sudo apt-get install -y docker.io

The solution:

Here we use the /etc/docker/daemon.json configuration file to change the storage driver.

Paste the following commands in a terminal:

# Create a config file to set the storage driver to "Device Mapper"
echo '{ "storage-driver": "devicemapper" }' | sudo tee -a /etc/docker/daemon.json > /dev/null

# Restart the Docker service
sudo service docker restart

Test

Now I can successfully run an Ubuntu container with the command

sudo docker run --rm -it ubuntu

Bad news for the future

Unfortunately, I'm not sure how much longer this approach will be supported. Running sudo docker info I see the following deprecation warning:

WARNING: the devicemapper storage-driver is deprecated, and will be removed in a future
release.
Ben Mares
  • 1,764
  • 1
  • 15
  • 26
  • Havent tried it yet running new version of docker in a live usb disk , but would you know if the new overlay2 storage drive works directly with the live usb? from what I'm reading this seems to be the new default driver instead of AUFS If it works with it, than it could be that just using the latest docker version is the best solution to the problem – Arruda Aug 06 '20 at 12:59
  • I agree, but the live USB seems to already mount as overlay and neither overlay nor overlay2 worked for me. Maybe it's possible with some tinkering, but on first glance it doesn't look promising. – Ben Mares Aug 06 '20 at 13:03
  • 1
    This solution worked for me on Ubuntu 20.04 Live on an SSD. – Ezward May 26 '21 at 20:57
1

I had similar issues but with Ubuntu 16.04. What I actually did to make it run

1) I installed docker on ubuntu live

    sudo apt-get update

    sudo apt-get install \
      apt-transport-https \
      ca-certificates \
      curl \
      gnupg-agent \

    curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
      software-properties-common

    sudo apt-key fingerprint 0EBFCD88

    sudo add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"

    sudo apt-get update

    sudo apt-get install docker-ce docker-ce-cli containerd.io

2) Once docker is installed on ubuntu live. You need to stop the docker using

    sudo service docker stop

3) Then edit the file on /lib/systemd/system/docker.service using

    sudo gedit /lib/systemd/system/docker.service

by replacing this line

    ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd  /containerd.sock

with this line

    ExecStart=/usr/bin/dockerd -g /media/ubuntu/something -H fd:// --containerd=/run/containerd  /containerd.sock

So basically what we have done is to add -g /media/ubuntu/something, which is the driver that will replace the ROOT DIR of docker. Note that if the driver is NTFS, this won't work. You need to have the driver as ext4 or FAT.

4) Once finished, reload the daemon

    sudo systemctl daemon-reload

5) restart the docker service

    sudo service docker restart

6) check that the ROOT DIR has changed by running

    sudo docker info

You should see the new directory there. After all, this is very cool since you can have portable images and containers and you can run them on any ubuntu machine just by doing the aforementioned. I haven't tested this on Windows but anyway it has always been painful for me to work with docker and windows.

Mohanad Y.
  • 18,278
  • 3
  • 12
  • 12
  • Hi @Mohanad Y. I want to setup docker on ubuntu live usb. But I want docker file to be saved on my MacBook's ssd drive instead of live usb's persistent storage. Do you happen to know how I can do so? Thanks :) – sorabh.v6 Aug 22 '19 at 04:12
  • 1
    Hi @sorabh.v6. The docker file can be anywhere on your machine (which is the file that you use to build a docker image). The only thing that matters is where the docker images and containers are stored, which is in this case the DOCKER ROOT. This ROOT directory must not be an NTFS format. – Mohanad Y. Aug 23 '19 at 08:15
  • So, that means I can store .raw file in which docker containers are stored in my macbooks storage, right?? because the macbook partition is not ntfs, its apfs – sorabh.v6 Aug 23 '19 at 14:42
  • 1
    The storage of docker containers is controlled by the ROOT DIR. So, if you change the ROOT DIR to the location of your macbook partition that is not an NTFS it should be fine. – Mohanad Y. Aug 26 '19 at 06:26