Docker Guide: Difference between revisions
Line 136: | Line 136: | ||
root@{{#var:MACHINE_NAME}}:~# docker-compose --version<br> | root@{{#var:MACHINE_NAME}}:~# docker-compose --version<br> | ||
docker-compose version 1.21.2, build e7de1bc<br> | docker-compose version 1.21.2, build e7de1bc<br> | ||
== Example 1: a RESTful-based data-logger | |||
The linked file [[File:Docker_Example01_RestDataLogger.zip]] provides an example of a RESTful-based data-logger to be deployed on an embedded device acting as an intelligent edge node in large connected networks. Through a developed Web service application based on the ''Tornado web framework'', data can be easily inserted and retrieved from a ''MongoDB'' instance by remote devices. | |||
In the tutorial the application is proposed as a '''Docker'''-based solution in which each component is a separate container. | |||
'''Docker Compose''' is used to simplify the build of custom Docker images, their deployment, and configuration. The application can be easily tested on personal computers and embedded devices supporting Docker and Docker Compose. |
Revision as of 00:21, 6 May 2020
Docker Introduction
Docker is an application that simplifies the process of managing application processes in containers.
Containers let you run your applications in resource-isolated processes. They’re similar to virtual machines, but containers
are more portable, more resource-friendly, and more dependent on the host operating system.
You can check Docker online documentation at:
https://docs.docker.com/get-started/
https://training.play-with-docker.com/
https://docker-curriculum.com/
Yocto Integration
Recipe
Before you begin, get familiar with the Varicite Yocto Build Release guide.
Variscite provides a light reference image with Docker, var-image-docker.
This image is based on the core-image bbclass with the addition of a few more packages and features:
- docker
- python3-docker-compose
- ssh-server-dropbear
- basic command line tools
Create a Docker-ready Image
- Follow steps 1-3 of the Yocto Build Release page.
$ cd ~/var-fslc-yocto $ MACHINE=var-som-mx6 DISTRO=fslc-x11 . setup-environment build_x11
Append the following to the conf/local.conf file in your Yocto build directory:
DISTRO_FEATURES_append = " virtualization"
$ bitbake var-image-docker
Test Docker
- Check target Internet connection
root@var-som-mx6:~# ping 8.8.8.8
- Get the target IP address.
- Open ssh terminal from host:
ssh root@<ip address>
- Check docker version.
root@var-som-mx6:~# docker --version
Docker version 18.09.3, build f5e591e
Test hello-world
root@var-som-mx6:~# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
256ab8fe8778: Pull complete
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest
- List docker images:
root@var-som-mx6:~# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
hello-world latest a29f45ccde2a 3 months ago 9.14kB
- Run hello-world:
root@var-som-mx6:~# docker run hello-world Hello from Docker!
This message shows that your installation appears to be working correctly. To generate this message, Docker took the following steps:
1. The Docker client contacted the Docker daemon.
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
(arm64v8)
3. The Docker daemon created a new container from that image which runs the
executable that produces the output you are currently reading.
4. The Docker daemon streamed that output to the Docker client, which sent it
to your terminal.
Test Ubuntu
root@var-som-mx6:~# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
b2f61026a351: Pull complete
5538fb30c42c: Pull complete
f0b05810781a: Pull complete
0180a33352d6: Pull complete
Digest: sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d
Status: Downloaded newer image for ubuntu:latest
- List docker images:
root@var-som-mx6:~# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ubuntu latest 428b2f74b0fb 2 weeks ago 57.7MB hello-world latest a29f45ccde2a 3 months ago 9.14kB
- Run ubuntu:
root@var-som-mx6:~# docker run -it ubuntu
root@8637148015f5:/# apt update
.................................
Fetched 16.3 MB in 11s (1471 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
12 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@8637148015f5:/# apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ca-certificates libc-ares2 libhttp-parser2.7.1 libicu60 libnghttp2-14 libssl1.0.0 libssl1.1 libuv1 nodejs-doc openssl
The following NEW packages will be installed:
ca-certificates libc-ares2 libhttp-parser2.7.1 libicu60 libnghttp2-14 libssl1.0.0 libssl1.1 libuv1 nodejs nodejs-doc openssl
0 upgraded, 11 newly installed, 0 to remove and 12 not upgraded.
Need to get 15.6 MB of archives.
After this operation, 62.8 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
...........................................
Updating certificates in /etc/ssl/certs...
0 added, 0 removed; done.
Running hooks in /etc/ca-certificates/update.d...
done.
root@8637148015f5:/# node -v
v8.10.0
root@8637148015f5:/# exit
Test docker-compose
- Check the docker-compose version:
root@var-som-mx6:~# docker-compose --version
docker-compose version 1.21.2, build e7de1bc
== Example 1: a RESTful-based data-logger
The linked file File:Docker Example01 RestDataLogger.zip provides an example of a RESTful-based data-logger to be deployed on an embedded device acting as an intelligent edge node in large connected networks. Through a developed Web service application based on the Tornado web framework, data can be easily inserted and retrieved from a MongoDB instance by remote devices.
In the tutorial the application is proposed as a Docker-based solution in which each component is a separate container. Docker Compose is used to simplify the build of custom Docker images, their deployment, and configuration. The application can be easily tested on personal computers and embedded devices supporting Docker and Docker Compose.