Docker is a software technology that provides operating system level virtualization. Functionality-wise it can be compared with a virtual machine, except that it suffers less of a performance penalty. On Linux it uses the resource isolation features of the Linux kernel to provide abstraction and process isolation. It allows you to create containers that run on Docker and are independent of the operating system underneath.
There are Docker instances of the Toaster user interface available, which will be introduced in this recipe.
- To install Docker on your Ubuntu 16.04 machine, add the GPG key for the official Docker repository to the system:
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
- Then add the Docker repository to APT sources:
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
- Next, update the package database with the Docker packages from the newly added repository:
$ sudo apt-get update$ sudo apt-get install docker-ce
- Add your user to the docker group:
$ sudo usermod -aG docker ${USER}$ su - ${USER}
- Finally, test run Docker by running the
hello-world
container:
$ docker run hello-world
- To run a
docker-toaster
instance, we will first create a directory in our host machine for thedocker
container to store the builds:
$ mkdir /opt/yocto/docker-toaster
- We can then instruct Docker to run the
crops/toaster
container and point its/workdir
directory to the local directory we just created:
$ docker run -it --rm -p 127.0.0.1:18000:8000 -v /opt/yocto/docker-toaster:/workdir crops/toaster
Note
If you see the following error:Refusing to use a gid of 0
Traceback (most recent call last):
File "/usr/bin/usersetup.py", line 62, in <module>
subprocess.check_call(cmd.split(), stdout=sys.stdout, stderr=sys.stderr)
File "/usr/lib/python2.7/subprocess.py", line 541, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['sudo', 'restrict_groupadd.sh', '0', 'toasteruser']' returned non-zero exit status 1
Make sure the /opt/yocto/docker-toaster
directory was created before running Docker and is not owned by root. If you don't create it beforehand, Docker will do it with the root user and the setup will fail as above.
See https://github.com/crops/poky-container/issues/20.
Note
Note that you can replace the 127.0.0.1
above with an IP address that is externally accessible if you are running Docker on a different machine.
$ docker ps
- You can now access the Toaster web interface at
http://127.0.0.1:18000
. - The
docker
container can be stopped with the following command:
$ docker stop <container-id>
- Django documentation can be accessed at https://docs.djangoproject.com/en/1.9/
- The Django management command available at
toaster/manage.py
is documented as part of the Django documentation at https://docs.djangoproject.com/en/1.9/ref/django-admin/ - Docker specific documentation can be accessed at https://docs.docker.com/engine/reference/commandline/dockerd/
- The Toaster
docker
container home page is https://github.com/crops/toaster-container