Home Blog Page 848

Introduction to Docker Compose Tool for Multi-Container Applications

Docker compose tutorial image

Docker is celebrating its third birthday this week, on March 23, but some of you may still not know about all the tools that come with Docker. In this blog we will introduce you to Docker Compose, one of the tools, which with the Docker Engine, Docker Machine and Docker Swarm, empowers developers to develop distributed applications.

If you have started working with Docker and are building container images for your application services, you most likely have noticed that after a while you may end up writing long `docker run` commands. These commands while very intuitive can become cumbersome to write, especially if you are developing a multi-container applications and spinning up containers quickly. 

Docker Compose is a “tool for defining and running your multi-container Docker applications”. Your applications can be defined in a YAML file where all the options that you used in `docker run` are now defined. Compose also allows you to manage your application as a single entity rather than dealing with individual containers.

In this tutorial we give you a brief introduction to Docker Compose, by building, you may have guessed…a Blog site.

Installing Docker Compose 

Just like the Docker engine, Compose is extremely easy to install. First verify that you have the Docker engine installed, since Compose will use it. Then if you are comfortable with it you can simply use `curl` to download the Compose binary. If you struggle with the following commands or need additional details, check the very good documentation

$ docker version
$ curl -L https://github.com/docker/compose/releases/download/1.6.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
$ docker-compose version

Running a Ghost blog

While you can read the entire documentation and go through the compose reference manual. Nothing beats trying this out to discover a new tool. To dive straight into using Compose we are going to run a Ghost blog using containers.

You can run Ghost in a standalone mode which uses an embedded SQlite database in a single container. It is simple, and you do not need Compose for this, but it breaks the principles of single service functionality per container and will not allow you to scale any components of your blog if you need to. Let’s see how to do it anyway:

$ docker pull ghost
$ docker run -d --name ghost -p 80:2368 ghost

Once the above commands are successful, you should be able to access Ghost with your browser on port 80 of the Docker host you are using. Using a small trick, we will use this single container deployment to get the Ghost configuration file and modify it for a multi-container setup. Copy the Ghost configuration file located in the container to your local file system using the `docker cp` command like so:

$ docker cp -L ghost:/usr/src/ghost/config.js ./config.js
$ cat config.js

Edit the development section of the config.js file, to point to a Mysql database. We will assume that you can reach a Mysql database with a DNS name of `mysql`. We will setup a ghost database, with a Ghost user and a password set to `password`. You could also use a config file that takes advantage of environment variable. For simplicity, in this blog, we override the Ghost config file like so:

[config.js]
database: {
           client: 'mysql',
           connection: {
               host     : 'mysql',
               user     : 'ghost',
               password : 'password',
               database : 'ghost',
               charset  : 'utf8'
           }
       },

For that new configuration to be used, you need to create a Dockerfile that will be used to build your own local image of Ghost using your custom config file. You could do this several different ways, but building your own image with a two line Dockerfile is as easy as it gets. Here is the Dockerfile: 

FROM ghost
COPY ./config.js /var/lib/ghost/config.js

This new Docker image will be built automatically in your Docker Compose file using the `build` argument.

Your Compose file takes the following form. Two services are defined, a Mysql service and a Ghost service. The Mysql service is configured via environment variables set in the docker-compose file. We use the official Mysql Docker image that Compose will automatically pull from the Docker hub. Port 3306 is exposed to other containers in the same network. The Ghost service is based on our custom image; it depends on the Mysql service to ensure that the database will start first. We expose the default port of Ghost `2368` to port 80 of our Docker host.

[yaml]
version: '2'
services:
 mysql:  
  image: mysql
  container_name: mysql
  ports:
   - "3306"
  environment:
   - MYSQL_ROOT_PASSWORD=root
   - MYSQL_DATABASE=ghost
   - MYSQL_USER=ghost
   - MYSQL_PASSWORD=password
 ghost:  
  build: ./ghost
  container_name: ghost
  depends_on:
    - mysql
  ports:
    - "80:2368"

This would be the equivalent of running the following `docker run` commands: 

$ docker run -d --name mysql -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=ghost -e MYSQL_PASSWORD=password -e MYSQL_USER=ghost -p 3306 mysql
$ docker build -t myghost .
$ docker run -d --name ghost -p 80:2368 myghost

Keeping all these steps in a single YAML configuration file will be easier to maintain and evolve than writing your own Docker commands wrapper in bash scripts. Plus compose allows you to manage the entire app and individual services. 

To start your Compose application, you just need to run `docker-compose up -d`. The two containers will get started and will be properly connected to each other on the network. You can then open your browser at `http://localhost>` and start using Ghost. To create new posts go to `http://localhost/ghost/setup>` create an account and start editing your posts. Once the containers have started you can view the state of your application as simply as with `docker-compose ps`. 

Ghost blog on Docker compose

[bash]
$ docker-compose up -d
Starting mysql
Starting ghost
$ docker-compose ps
Name            Command            State            Ports          
------------------------------------------------------------------
ghost   /entrypoint.sh npm start   Up      0.0.0.0:80->2368/tcp    
mysql   /entrypoint.sh mysqld      Up      0.0.0.0:32770->3306/tcp

Note that if you have used Compose before, in this example we use version ‘2’ of Compose. Hence we do not need links. The two services will take advantage of the embedded DNS server now running on Docker engine 1.10 and will be able to find each other using their service name. Hence if you want to ping ‘ghost’ from the mysql container you can and vice versa: 

[bash]
$ docker exec -ti mysql bash
root@b1e66140ddb3:/# ping ghost
PING ghost (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: icmp_seq=0 ttl=64 time=0.074 ms
64 bytes from 172.18.0.3: icmp_seq=1 ttl=64 time=0.222 ms

And voila! Docker Compose is a very handy tool that helps you write a distributed application definition in a single YAML file. It can handle most of the `docker run` options and since the last release also supports Docker networks and volumes. In following posts, we will dive into more advanced setup and use cases using Compose as well as the use of Docker Swarm to distribute your containers across a cluster of Docker hosts.

Qt 5.6 Goes LTS, Tightens Integration with Yocto Project

samegame-compareThe Qt Company released version 5.6 of its cross-platform application and UI development framework, bringing Qt’s Boot to Qt embedded Linux platform in greater alignment with Yocto Project tools. As a result, “developers can easily pull in the full Qt offering to their own Yocto-based software stacks or customize Qt’s Yocto-compliant software stack to meet their production needs,” says the Qt Company.

Among other enhancements, Qt 5.6 adds automatic scaling to high-resolution displays, as well as an improved Qt Virtual Keyboard, support for more embedded Linux boards, and improvements to Qt WebEngine. In addition, version 5.6 provides full Windows 10 support, and the ability to develop embedded Linux devices using a Windows host PC.

Qt 5.6 is also the first Long-Term Support (LTS) release since Qt 4.8 back in 2011 when the Qt project was still sponsored by Nokia. LTS brings assurances of patch releases and bug and security fixes for at least three years, and as Lars Knoll notes in his Qt 5.6 blog entry, gives the Qt team “some more freedom in the upcoming versions of Qt.”

Posting an LTS stake in the ground has enabled Qt to migrate to a new Continuous Integration System (COIN) for software development and release. The Qt Company, which offers both free open source and subscription-based commercial versions of Qt, has been moving to the new system over the last year, replacing the old Jenkins-based infrastructure. COIN enables much faster integration and testing of code changes, and works “much more incrementally, making it easier to bring all the repositories and source code…together,” writes Knoll.

With Qt 5.6, most of the release binaries are produced within the same system, which is said to significantly reduce package generation time. Also, for the first time, the Qt team can “efficiently support different configurations and platforms for different Qt branches,” writes Knoll.

The LTS release has also freed up Qt to cut ties with older platforms. The upcoming Qt 5.7 will require a C++11 compliant compiler and will drop some older, unnamed platforms. Qt 5.7 will also coincide with changes to licensing, including moving from LGPLv2.1 to LGPLv3, and “open-sourcing a lot of formerly closed components under GPL,” says the Qt Company.

Yocto Project on Tap

Embedded Linux developers work with a Qt module called Qt for Device Creation, which includes a Boot to Qt embedded workflow stack that enables fast startup on development boards. Previously, developers have been able to use Yocto Project tools to do some customization of Boot to Qt. Qt 5.6 has substantially improved Qt’s conformance with both the tools and Yocto meta layers.

With Qt 5.6, “it’s even easier to customize the Boot to Qt stack or pull in all relevant Qt pieces straight to your own Yocto-based builds,” writes Knoll. Hosted by the Linux Foundation, the open source Yocto Project provides developers with templates, tools, and methods to help create custom embedded Linux devices, regardless of the architecture. These include a development environment, emulation environments, debuggers, an Application Toolkit Generator, metadata, documentation, and OpenEmbedded core system component recipes.

The following are some key highlights of Qt. 5.6:

  • Improved Yocto Project support — See above.

  • LTS — Updates and patches are promised for at least three years when extended support can be purchased.

  • High-DPI support — Qt has expanded high resolution support beyond its Mac OS X version, enabling apps written for standard resolutions on any platform to automatically scale up to high-res displays. Qt can automatically adjust font sizes, window elements, icons, and more based on pixel density.

  • Windows 10 support — Qt 5.6 is the first release to provide full Windows 10 support, including PCs, tablets, and phones. A recompile will enable most apps to be distributed in the Windows Store. Windows Embedded Compact support has been updated to the 2013 version.

  • Windows host support for embedded Linux — Developers using the Windows version of Qt can now tap directly into Qt for Device Creation to develop apps for embedded Linux devices.

  • Browser improvements — The Qt WebEngine browser engine advances to Chromium 45, and adds support for Pepper plugins (PPAPI) such as Flash. There’s a module for new low-level APIs, and Linux users can now use “many of the system libraries instead of bundled ones.”

  • Qt Virtual Keyboard updates — The new keyboard app adds Hand Writing Recognition (HWR), performance improvements, Nuance T9 Write integration, and support for Traditional Chinese. It’s now available with GPLv3 licensing.

  • New embedded Linux hardware support — Qt 5.6 extends support for targets including the Nvidia Jetson Pro, Intel NUC, and systems using the NXP i.MX6.

  • Qt Location — There is now full support for the Qt Location module, enabling integration of maps, navigation, and points-of-interests (POIs) within Qt apps. Plugins are supplied for HERE, Mapbox, and OpenStreetMap.

  • Enhanced Qt APIs — Qt 5.6 offers improvements to C++11 support, Qt Multimedia, OpenGL ES 3 compatibility, and more.

  • Technology Previews — Preview releases for future Qt versions include an enhanced version of Qt 3D and a new Qt SerialBus for supporting CanBUS and ModBus. Qt Quick Controls 2 has been significantly revamped, and offers “improved performance especially on embedded devices.”

  • Qt Creator 3.6.0 — Qt 5.6 is compatible with the new Qt Creator 3.6.0 GUI design package. There’s an experimental editor for UML-style diagrams, plus improvements to the Clang-based C/C++ code model, and more. The release no longer supplies prebuilt binaries for 32-bit Linux.

  • Qt for Application Development discount — This week, Qt announced a Start-Up Plan that offers significant subscription reductions on its commercial Qt for Application Development program. Available only to companies with revenues of $100,000 or less, the $49 per month plan lacks professional Qt support. The company notes, however, that many of the roughly 1 million active Qt developers are happy to help out newbies on the Qt forums.

Quickie Qt Backgrounder

As several readers have pointed out, Qt probably should have been included in our January roundup of 10 Best Free Mobile Application Development Frameworks That Support Android. Qt is kind of a different breed, however. It supports GUI development in addition to full applications, it’s primarily focused on C++ rather than Javascript, and its Android and iOS support is still relatively new.

Since Digia acquired the commercial framework from Nokia in 2011, and took on stewardship of the open source Qt project in 2012, the Finnish company has focused on expanding mobile support. The first production-ready Qt ports of Android and iOS arrived in late 2013 in the beta version of Qt 5.2. This was enabled with Qt Quick and its declarative scripting language QML, which enabled Javascript integration.

Although Qt has been always cross-platform, and now supports Linux, Windows, OS X, Android, and iOS, among other platforms, its embedded implementation focuses on Linux. The original Qt, called Qt/X11, was available in both a pseudo open source Unix and proprietary Windows version by Norwegian firm Trolltech back in the early 1990s. A Linux version soon followed. In 2000, after considerable debate in the Linux community involving the KDE project, which used Qt, the development framework was released under the fully open source GPL v2.

Trolltech then expanded to the Mac, and in 2003, customized its Linux-ready Qtopia embedded stack, built on the Linux-based Qt/Embedded to expand beyond handhelds to support mobile phones. Qtopia was billed as “the de facto standard application platform for embedded Linux.”

Trolltech continued to grow, and in 2008, Nokia acquired the company for about $150 million, giving rise to speculation Nokia would phase out Symbian in favor of Qtopia Linux. Yet, in 2009, Nokia’s new Qt Software unit replaced Qtopia with a cross-platform Qt 4.5 and switched to an LGPL license.

Nokia was a partner with Intel in the new MeeGo Linux project, which included a mobile profile, but in 2011, hopes for a new MeeGo-driven Nokia died when Nokia announced a partnership with Microsoft. Nokia said it would backburner MeeGo and focus on Windows Phone. The next year, Nokia sold the commercial Qt business and open source project to Digia, which then spun off the Qt Company.

This Week in Linux News: SDN Reigns Supreme at ONS, The White House Requires Custom Code Sharing, & More.

dsc 6055-100650748-primary.idgeThis week in Linux news, Software Defined Networking takes the sportlight at the Open Networking Summit, The White House will require agencies using third-party vendors to share their code, and more! Get up to speed on the latest news in Linux/open source with this weekly digest.

1) As adoption of software defined networking (SDN) increases, open source reigns supreme at ONS.

Open Source is Center Stage at Open Networking Summit– CIO

2) U.S. Source Code Policy dictates that agencies contracting with third-party vendors to create new software are now required to secure unlimited rights to the underlying custom code.

White House Requires Agencies to Share Custom Code with Open-Source Community– SC Magazine

3) Microsoft is targeting Oracle customers with their new decision to port the SQL Server to Linux, Sam Varghese posits.

Why Microsoft is Porting SQL Server to Linux– ITWire Magazine

4) The new free ‘Intro to Cloud Infrastructure Technologies’ course is the second course partnership between The Linux Foundation & edX.

The Linux Foundation Announces Free ‘Intro to Cloud Infrastructure Technologies’ edX Course– betanews

5) Microsoft should “stop forcing companies to pay for its bogus Android patents” to be trusted by the open source community, writes Steven J. Vaughan-Nichols.

The One Thing Microsoft Must Do – But Won’t – to Gain Open-Source Trust– ZDNet

 

Speed up Apache with mod_pagespeed and Memcached on Debian 8

The page load time gets more and more important for websites to provide a better user experience and it is important for the search engine ranking as well. Google has developed the apache module “mod_pagespeed” to optimize and streamline the content delivery of the apache web server which reduces the load times of pages, especially when they use many assets like CSS files, javascript includes and images.

Read more at HowtoForge

ownCloud Pi Device to Run on Snappy Ubuntu Core 16.04 LTS and Raspberry Pi 3

We reported last year that ownCloud was in talks with WD (Western Digital) Labs to help them develop a community project that would bring a self-hosted cloud storage device in users’ homes. The idea behind the self-hosted device, which will be powered by the ownCloud Server software, was to combine a Raspberry Pi single-board computer with a Western Digital disk drive into an easy-to-install and out-of-the-box container.

Well, it looks like the community’s response was more than positive, and many great proposals and ideas were received for the ownCloud Pi project. And today, they have even greater news for us, as the first images are available for download.

‘Metaphor’ Stagefright Exploit Exposes Millions of Android Devices

The newly-discovered Stagefright variant can be used to break into Samsung, LG and HTC smartphones. 

Millions of Android devices are vulnerable to a new Stagefright exploit which can compromise a device in less than 20 seconds, researchers say. According to Israel-based NorthBit, the newly-disclosed Stagefright exploit, dubbed Metaphor, can be used in attacks against Nexus 5, LG G3, HTC One and Samsung Galaxy S5 mobile devices, which potentially leaves millions of devices open for exploit.

In a paper documenting their research (.PDF), the team said they created an exploit which impacts devices running on Android versions 2.2 and 4.0, while also bypassing ASLR on versions 5.0 and 5.1. 

Read more at ZDNet News

Black Duck Highlights Up-and-Coming Open Source Projects

You already know the big-name open source companies, like Red Hat,Docker and Talend. But what are the up-and-coming businesses in the open source space? A new report from Black Duck offers some vital insight, with special focus on containers, collaboration and artificial intelligence.

The report, titled “2015 Black Duck Open Source Rookies of the Year,” highlighted open source projects launched in 2015 that, in Black Duck’s estimation, are “shaping the future of open source software.”  Black Duck focuses on three main areas of open source innovation: The Docker container ecosystem, collaboration software for messaging and communication and artificial intelligence (AI).

Read more at The VAR Guy

Nmap 7.10 Security Scanner Adds Hundreds of OS/Version Fingerprints, New Scripts

nmap-7-10Gordon Lyon from the Nmap project, one of the most acclaimed network and security scanner open-source software used by millions of hackers and security experts worldwide, today, March 17, 2016, announced the release of Nmap 7.10.

Nmap 7.10 comes exactly four months after the major Nmap 7.00 release, which was in development for the past three years, bringing countless new features and improvements to the free and cross-platform network mapper and security scanner originally written by Gordon Lyon a.k.a. Fyodor Vaskovich.

Linux 4.6 Staging Has 1600+ Patches, ~400 Patches From Outreachy

Greg Kroah-Hartman on Thursday submitted his pull request of the staging area changes for targeting the Linux 4.6 kernel. Greg noted in the pull request, “Lots of little things here, over 1600 patches or so. [Notable] is all of the good Lustre work happening, those developers have finally woken up and are cleaning up their code greatly. The Outreachy intern application process is also happening, which brought in another 400 or so patches. Full details are in the very long shortlog.” 

So it looks like almost a quarter of the patches are from Outreachy, the group providing paid internships for women and other “underrepresented groups in tech” to work on the Linux kernel and related open-source projects.

Read more at Phoronix

Robolinux 8.4 LTS “Raptor” Series Announced, Based on Debian GNU/Linux 8 Jessie

robolinux-8-4-lts-raptor-seriesThe developer of the Robolinux project has announced the release of his latest Robolinux 8.4 LTS “Raptor” series of Debian-based operating systems, which includes numerous software updates and performance improvements.

Usually, the Robolinux developer announces only one edition at a time for a new major release of the GNU/Linux distribution, but today’s announcement includes details about the availability for download of the Robolinux 8.4 LTS Cinnamon, MATE, Xfce, and LXDE editions, as both 64-bit and 32-bit variants.