{"id":29652,"date":"2024-06-18T10:32:07","date_gmt":"2024-06-18T07:32:07","guid":{"rendered":"https:\/\/trueconf.com/blog\/?p=29652"},"modified":"2024-06-18T14:09:53","modified_gmt":"2024-06-18T11:09:53","slug":"how-to-create-and-launch-a-docker-container-with-trueconf-videosdk","status":"publish","type":"post","link":"https:\/\/trueconf.com/blog\/knowledge-base\/how-to-create-and-launch-a-docker-container-with-trueconf-videosdk","title":{"rendered":"How to create and launch a Docker container with TrueConf VideoSDK"},"content":{"rendered":"<h2>Docker and its differences from a virtual machine<\/h2>\n<p>Docker is a software solution used for automatic deployment and management of applications in the environments that support containers. This solution makes it possible to \u201cpack\u201d an application with all its environment and dependencies in a container that may be later deployed. Docker offers a set of commands for managing these containers. <\/p>\n<p>Docker and virtual machines have a similar purpose, but they interact with the operating system in different ways. The main distinction is that a virtual machine offers an additional abstraction layer over the real hardware and drivers while a Docker container directly interacts with the hardware of the host machine.<br \/>\n<!--more--><\/p>\n<h2>What is TrueConf VideoSDK?<\/h2>\n<p>TrueConf VideoSDK is a software solution for creating enterprise-level applications with integrated TrueConf video conferencing. It serves as the basis for TrueConf Room which means that TrueConf Room can be viewed as TrueConf VideoSDK with a full-featured web interface for managing video conferences. Check <a href=\"https:\/\/docs.trueconf.com\/videosdk\/en\/introduction\/common#overview\" target=\"_blank\" rel=\"noopener\">here<\/a> to learn more about TrueConf VideoSDK and its differences from TrueConf Room. TrueConf also provides a NuGet package to support .NET development. To learn more about this package, check <a href=\"https:\/\/www.nuget.org\/packages\/TrueConf.VideoSDK\/#readme-body-tab\" target=\"_blank\" rel=\"noopener\">here<\/a>. <\/p>\n<p>This toolkit helps developers create high-quality applications and facilitates the development process. With TrueConf VideoSDK, one can integrate video conferencing technologies into self-service or information kiosks and enterprise-based software. <\/p>\n<h2>Limitations of TrueConf VideoSDK within a container<\/h2>\n<p>The features of VideoSDK on a local machine and within a container are almost identical. The only difference is that the latter does not have Front-End. In other words, the main application screen and the conference layout cannot be displayed on a monitor. This issue is related to the restrictions imposed by containers.<\/p>\n<h2>How to deploy a container with VideoSDK on my PC<\/h2>\n<p>This example will show how to install and configure Docker and deploy a container on Debian 12. The content of the container will be TrueConf VideoSDK version 4.3. <\/p>\n<p>To install Docker on your OS:<\/p>\n<ol>\n<li>Update the list of packages, to do it run this command in the terminal: <\/li>\n<pre class=\"lang:default decode:true \" >sudo apt update<\/pre>\n<li>Run this command to install additional packages required for working with remote repositories:<\/li>\n<pre class=\"lang:default decode:true \" >sudo apt -y install ca-certificates curl gnupg lsb-release<\/pre>\n<li>Download and add the PGP key from the Docker repository. To do it, run this command:<\/li>\n<pre class=\"lang:default decode:true \" >curl -fsSL https:\/\/download.docker.com\/linux\/debian\/gpg | sudo gpg --dearmor -o \/usr\/share\/keyrings\/docker-archive-keyring.gpg<\/pre>\n<li>Run this command to add a Docker repository:<\/li>\n<pre class=\"lang:default decode:true \" >echo \"deb [arch=$(dpkg --print-architecture) signed-by=\/usr\/share\/keyrings\/docker-archive-keyring.gpg] https:\/\/download.docker.com\/linux\/debian $(lsb_release -cs) stable\" | sudo tee \/etc\/apt\/sources.list.d\/docker.list > \/dev\/null<\/pre>\n<li>Update the lists of available packages:<\/li>\n<pre class=\"lang:default decode:true \" >sudo apt update<\/pre>\n<li>Install Docker and additional packages with this command:<\/li>\n<pre class=\"lang:default decode:true \" >sudo apt -y install docker-ce docker-ce-cli containerd.io<\/pre>\n<\/ol>\n<h3>Launch and automatic startup of Docker<\/h3>\n<p>By default, Docker is disabled after installation. To launch it, run this command:<\/p>\n<pre class=\"lang:default decode:true \" >sudo systemctl start docker<\/pre>\n<p>To add Docker to the automatic startup, execute the command:<\/p>\n<pre class=\"lang:default decode:true \" >sudo systemctl enable docker<\/pre>\n<h3>Adding a user to a Docker group<\/h3>\n<p>By default, Docker is available only to the <b>root<\/b> user: if a Docker command is run by a regular user, an error message will be displayed in the terminal. To run Docker commands on behalf of a regular user without the <b>sudo<\/b> command, one should add the current user to the <b>docker<\/b> group which is created automatically during installation. Run this command to check if the group is available:<\/p>\n<pre class=\"lang:default decode:true \" >groups $USER<\/pre>\n<p>If this group was not created automatically due to some reason, one has to create it manually. To do it, run this command:<\/p>\n<pre class=\"lang:default decode:true \" >sudo groupadd docker<\/pre>\n<p>Next, to add the current user to the <b>docker group<\/b>, execute the command:<\/p>\n<pre class=\"lang:default decode:true \" >sudo usermod -aG docker user_name<\/pre>\n<p>, where  <code>user_name<\/code>  is the name of the user who should be added to the <b>docker<\/b> group. To check the result, execute the command:<\/p>\n<pre class=\"lang:default decode:true \" >docker ps<\/pre>\n<p>This command displays the list of launched containers.<\/p>\n<h3>Launching the first container<\/h3>\n<p>To make sure that Docker was installed correctly, mount a test image. For this purpose, execute the command:<\/p>\n<pre class=\"lang:default decode:true \" >docker run hello-world<\/pre>\n<p>This command will mount the program image from the Docker hub online repository (official Docker registry of software images which is used by default) and run it automatically. If Docker was installed and configured correctly, the phrase \u201c<b>Hello from Docker<\/b>\u201d will be displayed.<\/p>\n<h2>How to build a container with VideoSDK<\/h2>\n<h3>Building a container<\/h3>\n<p>A container is created  at the time of its launch. These processes are started with the command:<\/p>\n<pre class=\"lang:default decode:true \" >docker run<\/pre>\n<p>The utility program has to be given the image on the basis of which the container will be created as well as the Dockerfile, the configuration file that will include the instructions for creating the image. The image can be either local (stored on the computer) or point to the image that should be downloaded from the network (Docker hub and others). In this case, the image stored locally will be used.<\/p>\n<p>Download VideoSDK from our GitHub; please note that the option with Ubuntu 22.04 has to be selected.<\/p>\n<p style=\"text-align: center;\"><a class=\"btn-large green darken-1 waves-effect white_text span fs-fs18\" style=\"width: 320px\" href=\"https:\/\/github.com\/TrueConf\/pyVideoSDK\/blob\/main\/download.md#download-trueconf-videosdk-for-free\" target=\"_blank\" rel=\"noopener\">Download VideoSDK<\/a><\/p>\n<p>Click on the button below to download the archive with the Dockerfile.<\/p>\n<p style=\"text-align: center;\"><a class=\"btn-large green darken-1 waves-effect white_text span fs-fs18\" style=\"width: 320px\" href=\"https:\/\/trueconf.com\/blog\/wp-content\/uploads\/2024\/06\/dockerfile.zip\" target=\"_blank\" rel=\"noopener\">Download Dockerfile<\/a><\/p>\n<p>One should keep in mind that by default the processes within the container work on behalf of the root user, however, it is dangerous to work under the root account because this user cannot be restricted in any way. To make sure that no threats are posed to the local machine from inside the container, you need to create a user with the standard set of permissions when building the container.<\/p>\n<p>In this example, Dockerfile and VideoSDK image are in the same directory (<b>\/home\/$USER\/dockerresources\/videosdk<\/b>); otherwise, you need to specify the Dockerfile directory with the <code>-f<\/code> flag.The command for creating the container with VideoSDK will look in the following way:<\/p>\n<pre class=\"lang:default decode:true \" >docker build --build-arg username=sdkuser --build-arg password=123sdk456 -t tcvideosdk \/home\/$USER\/dockerresources\/videosdk<\/pre>\n<p>where:<\/p>\n<ul>\n<li><code>--build-arg username=sdkuser<\/code> \u2014 user name;<\/li>\n<li><code>--build-arg password=123sdk456<\/code> \u2014 user password;<\/li>\n<li><code>-t tcvideosdk<\/code> \u2014 image name;<\/li>\n<li><code>\/home\/$USER\/dockerresources\/videosdk<\/code> \u2014 path to the folder with the Dockerfile and container image.<\/li>\n<\/ul>\n<p>After the command is executed, the container will start to be built. Information about this entire process will be displayed in the terminal. When build is complete, the following message will be displayed:<\/p>\n<p><code>[+] Building 1169.1s (12\/12) FINISHED<\/code>. <\/p>\n<h3>Testing build<\/h3>\n<p>Run the created container with this command:<\/p>\n<pre class=\"lang:default decode:true \" >docker run -it -d -p 2222:8080 -p 3333:8765 -p 4444:8766 tcvideosdk:latest<\/pre>\n<p>where:<\/p>\n<ul>\n<li><code>-it<\/code> \u2014 connects the interactive <b>tty<\/b> terminal to the container;<\/li>\n<li><code>-d<\/code> \u2014 launches the container in the background;<\/li>\n<li><code>-p 3333:8765 -p 4444:8766 tcvideosdk:latest<\/code> \u2014 sets the ports for a Web socket and http port.<\/li>\n<\/ul>\n<p>To display the list of launched containers in the terminal, run this command:<\/p>\n<pre class=\"lang:default decode:true \" >docker ps<\/pre>\n<pre class=\"lang:default decode:true \" >\r\nalexadmin@DebDocker1:-5 dockerer run -it -d -p 2222:8080 -p 3333:8765 -p 4444:8766 tcvideosdk:latest f756fb106cedc657a51a90bad8996a03049e67d4a9402919e6b6b7aeada66ab4\r\nalexadmin@DebDocker1:-5 docker ps\r\nCONTAINER ID  IMAGE              COMMAND                 CREATED        STATUS        PORTS         NAMES\r\n1756fb106ced  tcvideosdk:latest  \"sh -c 'supervisord .\"  9 seconds ago  Up 8 seconds  0.0.0.0:2222->8080\/tcp, :::2222->8080\/tcp,0.0.0.0:3333->8765\/tcp, :::3333->8765\/tcp, 0.0.0.0:4444->8766\/tcp, :::4444->8766\/tcp  affectionate_dewdney\r\nalexadmin@DebDocker1:-5\r\n<\/pre>\n<p>As it is shown in the screenshot above, the container has been launched successfully, and is displayed in the terminal. Check the availability of <b>3333<\/b> and <b>4444<\/b> ports with this command:<\/p>\n<pre class=\"lang:default decode:true \" >telnet localhost port<\/pre>\n<p>where port is the port that has to be checked.<\/p>\n<pre class=\"lang:default decode:true \" >\r\nalexadmin@DebDocker 1:~$ telnet localhost 3333\r\nTrying ::1\u2026\r\nConnected to localhost.\r\nEscape character is ']'.\r\nConnection closed by foreign host.\r\nalexadmin@DebDocker 1:~$ telnet localhost 4444\r\nTrying : : 1.\r\nConnected to localhost.\r\nEscape character is\r\nConnection closed by foreign host.\r\n<\/pre>\n<p>The message \u201c<b>Connected to localhost<\/b>\u201d is displayed in the terminal, which means that the port is working. <\/p>\n<p>To test the http port and Web socket, make an http request:<\/p>\n<pre class=\"lang:default decode:true \" >http:\/\/10.140.2.233:2222\/public\/default\/config.json<\/pre>\n<p>This request should return the following data:<\/p>\n<pre class=\"lang:default decode:true \" >\r\n{\"config\":\r\n  {\"websocket\":\r\n    {\"hostname\":null,\r\n    \"port\":8765},\r\n  \"http\":\r\n    {\"hostname\":null,\r\n    \"port\":8766}\r\n    }\r\n  }\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Docker and its differences from a virtual machine Docker is a software solution used for automatic deployment and management of applications in the environments that support containers. This solution makes it possible to \u201cpack\u201d an application with all its environment and dependencies in a container that may be later deployed. Docker offers a set of [&hellip;]<\/p>\n","protected":false},"author":73,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[260],"tags":[246,272],"class_list":["post-29652","post","type-post","status-publish","format-standard","hentry","category-knowledge-base","tag-api-and-sdk","tag-trueconf-sdk","wpautop"],"_links":{"self":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/29652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/users\/73"}],"replies":[{"embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/comments?post=29652"}],"version-history":[{"count":8,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/29652\/revisions"}],"predecessor-version":[{"id":29688,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/posts\/29652\/revisions\/29688"}],"wp:attachment":[{"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/media?parent=29652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/categories?post=29652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trueconf.com/blog\/wp-json\/wp\/v2\/tags?post=29652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}