Docker Guide: Difference between revisions
No edit summary |
|||
Line 5: | Line 5: | ||
= Docker Introduction = | = Docker Introduction = | ||
Docker is a software platform that allows the creation, testing and distribution of applications via containers.<br> | |||
Docker is | Containers let you run your applications in resource-isolated processes. There are some similarities to virtual machines, but | ||
Containers let you run your applications in resource-isolated processes. | containers are more portable, more resource-friendly, and enables faster software delivery cycles.<br> | ||
are more portable, more resource-friendly, and | Often used with docker there's a companion tool known as docker-compose: compose is used for defining and running multi-container Docker applications.<br> | ||
<br> | <br> | ||
You can check Docker online documentation at:<br> | You can check Docker online documentation at:<br> | ||
https://docs.docker.com/get-started/<br> | https://docs.docker.com/get-started/<br> | ||
https://docs.docker.com/compose/<br> | |||
https://training.play-with-docker.com/<br> | https://training.play-with-docker.com/<br> | ||
https://docker-curriculum.com/<br> | https://docker-curriculum.com/<br> | ||
Line 38: | Line 39: | ||
Append the following to the conf/local.conf file in your Yocto build directory: | Append the following to the conf/local.conf file in your Yocto build directory: | ||
DISTRO_FEATURES_append = " virtualization" | DISTRO_FEATURES_append = " virtualization" | ||
Line 44: | Line 44: | ||
= Test Docker = | = Test Docker = | ||
* Check | * Check docker version:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker --version | |||
== Test hello-world == | |||
* | * Pull the hello-world image from Docker Hub:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker pull hello-world | |||
root@{{#var:MACHINE_NAME}}:~# docker pull hello-world | |||
* List docker images:<br> | * List docker images:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker images | |||
* Run hello-world:<br> | * Run hello-world container:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker run hello-world | |||
Hello from Docker!<br> | |||
This message shows that your installation appears to be working correctly. | |||
To generate this message, Docker took the following steps:<br> | |||
1. The Docker client contacted the Docker daemon.<br> | |||
2. The Docker daemon pulled the "hello-world" image from the Docker Hub.<br> | |||
3. The Docker daemon created a new container from that image which runs the<br> | |||
executable that produces the output you are currently reading.<br> | |||
4. The Docker daemon streamed that output to the Docker client, which sent it<br> | |||
to your terminal. | |||
== Test Ubuntu == | == Test Ubuntu == | ||
* Pull the ubuntu image from Docker Hub:<br> | |||
root@{{#var:MACHINE_NAME}}:~# docker pull ubuntu | |||
* Run ubuntu:<br> | * Run ubuntu:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker run -it ubuntu<br> | |||
root@8637148015f5:/# apt update<br> | |||
…<br> | |||
root@8637148015f5:/# apt install nodejs<br> | |||
…<br> | |||
root@8637148015f5:/# node -v<br> | |||
…<br> | |||
root@8637148015f5:/# exit<br> | |||
root@{{#var:MACHINE_NAME}}:~# | |||
= Test docker-compose = | = Test docker-compose = | ||
* Check the docker-compose version:<br> | * Check the docker-compose version:<br> | ||
root@{{#var:MACHINE_NAME}}:~# docker-compose --version | |||
== Example: a RESTful-based data-logger == | == Example: a RESTful-based data-logger == |
Revision as of 09:32, 9 June 2020
Docker Introduction
Docker is a software platform that allows the creation, testing and distribution of applications via containers.
Containers let you run your applications in resource-isolated processes. There are some similarities to virtual machines, but
containers are more portable, more resource-friendly, and enables faster software delivery cycles.
Often used with docker there's a companion tool known as docker-compose: compose is used for defining and running multi-container Docker applications.
You can check Docker online documentation at:
https://docs.docker.com/get-started/
https://docs.docker.com/compose/
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 docker version:
root@var-som-mx6:~# docker --version
Test hello-world
- Pull the hello-world image from Docker Hub:
root@var-som-mx6:~# docker pull hello-world
- List docker images:
root@var-som-mx6:~# docker images
- Run hello-world container:
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.
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
- Pull the ubuntu image from Docker Hub:
root@var-som-mx6:~# docker pull ubuntu
- Run ubuntu:
root@var-som-mx6:~# docker run -it ubuntu
root@8637148015f5:/# apt update
…
root@8637148015f5:/# apt install nodejs
…
root@8637148015f5:/# node -v
…
root@8637148015f5:/# exit
root@var-som-mx6:~#
Test docker-compose
- Check the docker-compose version:
root@var-som-mx6:~# docker-compose --version
Example: a RESTful-based data-logger
This archive 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 run in 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 any device which supports Docker and Docker Compose, be it a PC or an embedded device.