Install Opencv in docker (ubuntu) build app in docker
How to run and build an application based on Opencv in a Docker container is the purpose of this tutorial. The process described below is how to install the Docker engine on the Windows machine, by command line download the base Ubuntu image, install Opencv inside the container, and commit changes to create your own image to save your installation to add whatever OpenCV app you want to scale in Docker. Cool? No magic. Really
Install Docker in Windows
The important thing is that Windows running docker-machine in Hyper-V virtual machine is available under Windows 10. If you select this installation you can have troubles with Virtual Box no longer working after Hyper-V is set to enable.. There is an option use also install based on Oracle Virtual Box but I selected easy to install using the first option which is nicely integrated with Windows 10 and brings me the advantage of docker development under Ubuntu on windows machines..
For the installation just follow the step-by-step tutorial on first link for Hyper-V-based installation
Download and install Links ! Read text before!
To download Docker for Windows Hyper-V use this link
To download Docker for Windows use Oracle VirtualBox link
Play with docker
After the easy installation, you should have the available icon in Windows like in the following image.
This allows you to control your docker engine like start stop and update, all the work is done by easy commands in the CMD command line.. Do not worry of the command line. It is easy to like to write an email..
The installed docker is now available through cmd line..
You can simply verify by issuing a command as me docker help and if you have successfully installed docker you should see the same output of possible command options.
Docker basics
Just briefly about docker. I try to use the simplest words to describe this. By issuing the command docker ps you can see that i do not have anything set up. The main components are the docker container and image.
Docker image
It is easy, Image is something like CD, all you need to install is there ready to be used by a specific application. Most often the application you want to develop is included in this image. For example, basic Ubuntu installation. This image could be extended to satisfy the specific needs of the developer.
Docker contained
The container is running an image instance. I have one image with Ubuntu and HTTP server inside. I could run from one image several containers with exactly the same settings. This allows me easy scalable deployment of my application from 10 users on one container t hundreds of containers of the same app and setting from this base image. The CD that could be installed several times is just a container.
Install OpenCV in Ubuntu docker image
You can use different kinds of images to start. I would like to recommend Ubuntu, where we install our OpenCV library. The process is that you take some base images from an already existing repository. This is just a setup in which you run the container and the image is basically downloaded in the background. After you install OpenCV and prerequisites and commit changes inside the container. This commit creates your unique image with your saved changes (installed) OpenCV and saves locally.. If you skip this step your changes inside the container are lost.
C:\docker run -it ubuntu bash
By issuing this command you run Ubuntu basic container and start the Ubuntu bash command line.. You can exit the bash command line inside Ubuntu container by typing EXIT.
I just issued a different command docker run -it ID_of_image bash because I have already image installed. But after you issue C:\docker run -it ubuntu bash you will be inside Linux like in the picture below.
Now install opencv following the documentation.
All is done in bash ubuntu command line. Again no mystery and who is afraid of the command line is just because he used to work in a different environment. But it is necessary and behind is nothing really hard. Now we follow exactly the same installation for Linux distribution, I got something for Debian here just a short version but you will be find it with the following approach..
1. install Required dependencies
We are the root which means sudo is not necessary, just copy these 3 lines one by one and follow the several instructions. Basically sometimes is writes Y to the command line. Nothing else.
apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
Now you have everything you need to build OpenCV. Now issue this command to download source code from git. This will create you the OpenCV folder, and after by cd jump into the OpenCV folder. By issuing mkdir build you create a new directory. Name as build! Jump into by CD build.. You can start installing right now.
cd opencv
mkdir build
cd build
Now you are in the build folder. This one is empty but is under the OpenCV where the all source code is located. Here just run the following command for basic configuration.. Now take some time and after you will see some overview of what is available to be installed. For example, avlibs to use video captures and other opencv vide options.. Do not forget the dots on the next line :)
Now is time to issue another command which builds your OpenCV from source based on cmake configuration. By typing simple make in Linux bash.
But just make is quite fine. Now these steps take several minutes. 10 to 40 depends on how much power and -j jobs you run to make opencv. The last is to install OpenCV into the system by make an install.
Done, your library is ready and you can develop your app under Linux (But this will be in next tutorial) in docker (/usr/local/lib) check the screenshot below for location cd /usr/local/lib , and list them by ls to display this.
NOW we need to save what is in our container. When we are saving a new container we create new images from we are starting containers.
!!Do not issue an exit yet.. save first!!
Save changes means - committing and creating a new image
This creates a new image with all the changes and allows you to start a container from this image with all the configuration from the previous step. Maybe run 1000 containers to serve the video application for millions of customers. Open new command line windows like on the image. Run commands that display the running container docker -ps.
Now from new cmd line save the container by this command in c:\> docker commit your_container_id name/description:version ,BE sure that c3f279d17e0a is the same container id obtain by docker -ps command.. For example.
This take some time and create your local image. Then could be again started by the same command.
Really, you blog has interesting and very valuable information about the translation.
sbobet
ทางเข้า sbo
ทางเข้า sbobet
I understand its system.
แทงบอล sbobet
แทงบอลออนไลน์
เว็บแทงบอล
Wow, this is quite amazing. I think it would be that many people still find these stories.
บาคาร่าออนไลน์
goldenslot
goldenslot
รับทำ SEO โปรโมท เว็บไซต์
GREAT ARTICLE! It is really interesting to read from the beginning & I would like to share your blog to my circles, keep sharing… DevOps Online Training
DevOps Online Training
Hi,
Thank your for the very useful tutorial. You mention about the next tutorial at the end of this tutorial which would be about building apps using Visual Studio and the prepared environment. How can I reach that tutorial if you have done that already?
Thank you in advance.
Before you write apt-get install build-essential you should execute the update command first. Correcting that instruction:
First, execute: apt-get update
Then: apt-get install build-essential
This, work for me.