List All Containers on Docker

Docker is a piece of software that allows you to run a complete filesystem in its own environment like a virtual machine by using containers to wrap up the environment. It will contain all of this together to run code, runtime, system tools, and system libraries, which is everything you need to run your own server.It is different in the architecture of virtual machines as all of the containers share the same kernel as the other containers but all other dependencies can run in isolation.This uses a config file to add all the dependencies you need on your server for your application to run correctly, for example, if your application needs a certain version of PHP to run, then creating a Docker environment will allow you to easily share the same environment with all developers on the project. If all developers are creating the application on the exact same environment as the live system will be on, it will make testing a lot easier allowing deployment to happen much faster and easier.Learn More About Using DockerList All ContainersThe below command will show all the current containers you have on Docker.docker psTo see all the current containers including those that aren't running you need to use the -l flag.docker ps -lOnce you have a list of all the containers you can attach to a certain container by using the container ID you get back from the list.docker attach {CONTAINERID} Read more

Einstein 2.0: gravitational waves detected for a second time

CAPE CANAVERAL, Fla.,  The ground-breaking detection of gravitational waves, ripples in space and time postulated by Albert Einstein 100 years ago, that was announced in February was no fluke. Scientists said on Wednesday that they have spotted them for a second time.The researchers said they detected gravitational waves that washed over Earth after two distant black holes spiraled toward each other and merged into a single, larger abyss 1.4 billion years ago. That long-ago violent collision set off reverberations through spacetime, a fusion of the concepts of time and three-dimensional space.These gravitational waves were observed by twin observatories in the United States late on Dec. 25, 2015 (early on Dec. 26 GMT). The detectors are located in Livingston, Louisiana, and Hanford, Washington.The first detection of gravitational waves was made in September and announced on Feb. 11. It created a scientific sensation and was a benchmark in physics and astronomy, transforming a quirky implication of Einstein's 1916 theory of gravity into the realm of observational astronomy.The waves detected in September and December both were triggered by the merger of black holes, which are regions so dense with matter that not even photons of light can escape the gravitational sinkholes they produce in space. The merging black holes that set space ringing in December were much smaller than the first pair, demonstrating the sensitivity of the recently upgraded Laser Interferometer Gravitational-wave Observatory, or LIGO, facilities."We are starting to get a glimpse of the kind of new astrophysical information that can only come from gravitational-wave detectors," said Massachusetts Institute of Technology researcher David Shoemaker. The black holes that triggered the newly detected gravitational waves were eight and 14 times more massive than the sun, respectively, before merging into a single, spinning black hole about 21 times more massive than the sun. The equivalent of one sun's worth of mass was transformed into gravitational energy.The Louisiana site detected the waves first and the Washington state detector picked up the signal 1.1 milliseconds later. Scientists can use the timing difference to calculate a rough idea of where the black holes merger occurred. Scientists say the second detection confirms that pairs of black holes are relatively common.  "Now that we are able to detect gravitational waves, they are going to be a phenomenal source of new information about our galaxy and an entirely new channel for discoveries about the universe," Pennsylvania State University astrophysicist Chad Hanna said.The research, presented at the American Astronomical Society meeting in San Diego, will be published in the journal Physical Review Letters. (Reporting by Irene Klotz; Editing by Will Dunham) Read more

Private company wants U.S. clearance to fly to the moon

WASHINGTON U.S. government agencies are working on temporary rules to allow a private company to land a spacecraft on the moon next year, while Congress weighs a more permanent legal framework to govern future commercial missions to the moon, Mars and other destinations beyond Earth's orbit, officials said.Plans by private companies to land spacecraft on the moon or launch them out of Earth's orbit face legal obstacles because the United States has not put in place regulations to govern space activities, industry and government officials said."We do not have formal authority today to deal with what happens on orbit or on other planetary terrestrial bodies. That’s the issue that we’re wrestling with,” said George Nield, head of the Federal Aviation Administration’s Office of Commercial Space Transportation.“What is being looked at right now is a Band-Aid fix because the system is broken,” Nield said at an American Bar Association space law forum in Washington on Wednesday. A 1967 international treaty obliges the United States and other signatories to authorize and supervise space activities by its non-government entities. But no U.S. agency has authority to regulate commercial space activities outside of rocket launches, spacecraft re-entries into the atmosphere and operations of telecommunications and remote sensing satellites in Earth orbit.The issue is coming to a head in part because of a request by Florida-based Moon Express for permission from the U.S. government to land a spacecraft on the moon in 2017. So far, only government agencies have flown satellites beyond Earth’s orbit. “No commercial company has ever asked to go outside of Earth orbit and go elsewhere before. We’re a pathfinder out of necessity,” Moon Express Chief Executive Bob Richards said in an interview on Monday.Richards and Nield declined to comment on what specifically Moon Express is proposing. Other countries are moving faster to establish rules for space launches in compliance with international treaties. Luxembourg last week announced it was partnering with two U.S. companies interested in mining asteroids and set aside 200 million euros to woo space firms to relocate. The United Arab Emirates also intends to serve as a commercial space haven.“We don’t want to create the environment where there’s a competitive advantage for payloads to go overseas,” said space attorney Michael Gold, who chairs the FAA’s commercial space advisory panel. (Reporting by Irene Klotz; Editing by Bill Trott) Read more

Microservice Architectures With Spring Cloud and Docker

This article provides a starting point for understanding common Microservice architecture patterns by example of a proof-of-concept application built with Spring Boot, Spring Cloud, and Docker.The code is available on Github, and images are available on Docker Hub. You can start the whole system with just one command.As a basis for this system I chose an old project, whose backend used to be a monolith. The application provides a way to deal with personal finances, organize incomes and expenses, manage savings, analyze statistics, and create simple forecasts.Functional ServicesThe monolith application was decomposed into three core microservices. All of them are independently deployable applications, organized around certain business capabilities.Account ServiceContains general user input logic and validation: incomes/expenses items, savings, and account settings.MethodPathDescriptionUser authenticatedAvailable from UIGET/accounts/{account}Get specified account dataGET/accounts/currentGet current account data××GET/accounts/demoGet demo account data (pre-filled incomes/expenses items, etc)×PUT/accounts/currentSave current account data××POST/accounts/Register new account×Statistics ServicePerforms calculations on major statistics parameters and captures time series for each account. A datapoint contains values normalized to base currency and time period. This data might be used to track cash flow dynamics in an account's lifetime.MethodPathDescriptionUser authenticatedAvailable from UIGET/statistics/{account}Get specified account statisticsGET/statistics/currentGet current account statistics××GET/statistics/demoGet demo account statistics×PUT/statistics/{account}Create or update time series datapoint for specified accountNotification ServiceStores a user's contact information and notification settings (like remind and backup frequency). Scheduled worker collects required information from other services and sends e-mail messages to subscribed customers.MethodPathDescriptionUser authenticatedAvailable from UIGET/notifications/settings/currentGet current account notification settings××PUT/notifications/settings/currentSave current account notification settings××NotesEach microservice has it's own database, so there is no way to bypass the API and access persistance data directly.For this project, I used MongoDB as the primary database for each service. It also might make sense to have a polyglot persistence architecture (to сhoose the type of database that is best suited to the service requirements).Service-to-service communication is quite simplified: microservices talking using only synchronous REST API. Common practice in a real-world systems is to use combination of interaction styles. For example, perform synchronous GET request to retrieve data and use asynchronous approach via Message broker for create/update operations in order to decouple services and buffer messages. However, this brings us in eventual consistency world.Infrastructure ServicesThere's a bunch of common patterns in distributed systems, which could help us to make described core services work. Spring cloud provides powerful tools that enhance Spring Boot applications behaviour to implement those patterns. I'll cover them briefly.Config ServiceSpring Cloud Config is horizontally scalable centralized configuration service for distributed systems. It uses a pluggable repository layer that currently supports local storage, Git, and Subversion. In this project, I use native profile, which simply loads config files from the local classpath. You can see shareddirectory in Config service resources. Now, when Notification-service requests it's configuration, Config service responses with shared/notification-service.yml and shared/application.yml (which is shared between all client applications).Client-side UsageJust build Spring Boot application with spring-cloud-starter-config dependency, autoconfiguration will do the rest.Now you don't need any embedded properties in your application. Just provide bootstrap.yml with the application name and Config service url:spring: application: name: notification-service cloud: config: uri: http://config:8888 fail-fast: trueWith Spring Cloud Config, You Can Change App Configuration DynamicallyFor example, the EmailService bean was annotated with @RefreshScope. That means you can change e-mail text and subject lines without rebuilding and restarting the Notification service application.First, change the required properties in the Config server. Then, perform the refresh request to the Notification service: curl -H "Authorization: Bearer #token#" -XPOST could also use webhooks to automate this process.NotesThere are some limitations for dynamic refreshes though. @RefreshScope doesn't work with @Configuration classes and can't affect @Scheduled property means that the Spring Boot application will fail startup immediately if it cannot connect to the Config Service. That's very useful when you're starting all applications together.There are significant security notes below.Auth ServiceAuthorization responsibilities are completely extracted to separate server, which grants OAuth2 tokens for backend resource services. Auth Server is used for user authorization as well as for secure machine-to-machine communication inside a perimeter.In this project, I use Password credentials as a grant type for user authorization (since it's only used by the native application UI) and Client Credentials as a grant type for microservices authorization.Spring Cloud Security provides convenient annotations and autoconfigurations to make this really easy to implement from both the server and client side. You can learn more about it in the documentation and check configuration details in Auth Server code.From the client side, everything works exactly the same as with traditional session-based authorization. You can retrieve Principal objects from request, check user roles and other stuff with expression-based access control and @PreAuthorize annotation.Each client in PiggyMetrics (account-service, statistics-service, notification-service and browser) has a scope: serverfor backend services, and ui - for the browser. So we can also protect controllers from external access, for example:@PreAuthorize("#oauth2.hasScope('server')") @RequestMapping(value = "accounts/{name}", method = RequestMethod.GET) public List getStatisticsByAccountName(@PathVariable String name) { return statisticsService.findByAccountName(name); }API GatewayAs you can see, there are three core services, which expose external APIs to the client. In a real-world system, this number can grow very quickly as well as whole system complexity. Actuallyy, hundreds of services might be involved in rendering one complex webpage.In theory, a client could make requests to each of the microservices directly. But obviously there are challenges and limitations with this option, like necessity to know all endpoints addresses, perform http request for each peace of information separately, merge the result on a client side. Another problem is non-web-friendly protocols, which might be used on the backend.Usually a much better approach is to use an API Gateway. It is a single entry point into the system, used to handle requests by routing them to the appropriate backend service or by invoking multiple backend services and aggregating the results. Also, it can be used for authentication, insights, stress and canary testing, service migration, static response handling, active traffic management.Netflix open sourced such an edge service, and now with Spring Cloud we can enable it with one @EnableZuulProxyannotation. In this project, I use Zuul to store static content (UI application) and to route requests to the appropriate microservices. Here's a simple prefix-based routing configuration for the Notification service:zuul: routes: notification-service: path: /notifications/** serviceId: notification-service stripPrefix: false That means all requests starting with /notifications will be routed to Notification service. There is no hardcoded address, as you can see. Zuul uses Service discovery mechanism to locate Notification service instances and also Circuit Breaker and Load Balancer, described below.Service DiscoveryAnother commonly known architecture pattern is service discovery. It allows automatic detection of network locations for service instances, which could have dynamically assigned addresses because of auto-scaling, failures, and upgrades.The key part of service discovery is the registry. I used Netflix Eureka for this project. Eureka is a good example of the client-side discovery pattern, when the client is responsible for determining the locations of available service instances (using a registry server) and load balancing requests across them.With Spring Boot, you can easily build Eureka Registry with a spring-cloud-starter-eureka-server dependency, @EnableEurekaServer annotation, and simple configuration properties.Client support is enabled with @EnableDiscoveryClient annotation and bootstrap.yml with application name:spring: application: name: notification-serviceNow, on application startup, it will register with Eureka Server and provide meta-data, such as host and port, health indicator URL, home page, etc. Eureka receives heartbeat messages from each instance belonging to a service. If the heartbeat fails over a configurable timetable, the instance will be removed from the registry.Also, Eureka provides a simple interface, where you can track running services and the number of available instances: http://localhost:8761Load Balancer, Circuit Breaker, and Http ClientNetflix OSS provides another great set of tools. RibbonRibbon is a client side load balancer which gives you a lot of control over the behavior of HTTP and TCP clients. Compared to a traditional load balancer, there is no need of an additional hop for every over-the-wire invocation — you can contact the desired service directly.Out of the box, it natively integrates with Spring Cloud and Service Discovery. Eureka Client provides a dynamic list of available servers so Ribbon could balance between them.HystrixHystrix is the implementation of a Circuit Breaker pattern, which gives a control over latency and failure from dependencies accessed over the network. The main idea is to stop cascading failures in a distributed environment with a large number of microservices. That helps to fail fast and recover as soon as possible — important aspects of fault-tolerant systems that self-heal.Besides circuit breaker control, with Hystrix you can add a fallback method that will be called to obtain a default value in case the main command fails.Moreover, Hystrix generates metrics on execution outcomes and latency for each command, that we can use to monitor system behavior.FeignFeign is a declarative HTTP client, which seamlessly integrates with Ribbon and Hystrix. Actually, with one spring-cloud-starter-feign dependency and @EnableFeignClients annotation you have a full suite of a load balancer, circuit breaker, and HTTP client with a sensible ready-to-go default configuration.Here is an example from Account Service:@FeignClient(name = "statistics-service") public interface StatisticsServiceClient { @RequestMapping(method = RequestMethod.PUT, value = "/statistics/{accountName}", consumes = MediaType.APPLICATION_JSON_UTF8_VALUE) void updateStatistics(@PathVariable("accountName") String accountName, Account account); }Everything you need is just an interfaceYou can share @RequestMapping part between Spring MVC controller and Feign methodsAbove example specifies just desired service id - statistics-service, thanks to autodiscovery through Eureka (but obviously you can access any resource with a specific url)Monitor DashboardIn this project configuration, each microservice with Hystrix on board pushes metrics to Turbine via Spring Cloud Bus (with AMQP broker). The Monitoring project is just a small Spring boot application with Turbine and Hystrix Dashboard.Let's see our system behavior under load: Account service calls Statistics service and it responses with a vary imitation delay. Response timeout threshold is set to 1 second.0 ms delay500 ms delay800 ms delay1100 ms delayWell behaving system. The throughput is about 22 requests/second. Small number of active threads in Statistics service. The median service time is about 50 ms.The number of active threads is growing. We can see purple number of thread-pool rejections and therefore about 30-40% of errors, but circuit is still closed.Half-open state: the ratio of failed commands is more than 50%, the circuit breaker kicks in. After sleep window amount of time, the next request is let through.100 percent of the requests fail. The circuit is now permanently open. Retry after sleep time won't close circuit again, because the single request is too slow.Log AnalysisCentralized logging can be very useful when attempting to identify problems in a distributed environment. Elasticsearch, Logstash, and Kibana stack lets you search and analyze your logs, utilization and network activity data with ease. Ready-to-go Docker configuration is described in my other project.SecurityAn advanced security configuration is beyond the scope of this proof-of-concept project. For a more realistic simulation of a real system, consider using https and JCE keystore to encrypt microservices passwords and Config server properties content (see documentation for details).Infrastructure AutomationDeploying microservices, with their interdependence, is a much more complex process than deploying a monolith application. It is important to have a fully automated infrastructure. We can achieve following benefits with a Continuous Delivery approach:The ability to release software anytime.Any build could end up being a release.Build artifacts once, deploy as needed.Here is a simple Continuous Delivery workflow, implemented in this project:In this configuration, Travis CI builds tagged images for each successful Git push. So there is  always a latest image for each microservice on Docker Hub and older images are tagged with Git commit hash. It's easy to deploy any of them and quickly roll back, if needed.How to Run All the Things?It's really easy and I suggest you to try. Keep in mind, that you are going to start 8 Spring Boot applications, 4 MongoDB instances, and RabbitMq. Make sure you have 4 Gb RAM available on your machine. You can always run just vital services though Gateway, Registry, Config, Auth Service, and Account Service.Before You StartInstall Docker and Docker Compose.Export environment variables: CONFIG_SERVICE_PASSWORD, NOTIFICATION_SERVICE_PASSWORD, STATISTICS_SERVICE_PASSWORD, ACCOUNT_SERVICE_PASSWORD, MONGODB_PASSWORDProduction ModeIn this mode, all of the latest images will be pulled from Docker Hub. Just copy docker-compose.yml and hit docker-compose up -d.Development ModeIf you'd like to build images yourself (with some changes in the code, for example), you have to clone all repository and build artifacts with Maven. Then, run docker-compose -f docker-compose.yml -f up inherits docker-compose.yml with additional possibility to build images locally and expose all containers ports for convenient development.Important Endpointslocalhost:80 - Gatewaylocalhost:8761 - Eureka Dashboardlocalhost:9000 - Hystrix Dashboardlocalhost:8989 - Turbine stream (source for Hystrix Dashboard)localhost:15672 - RabbitMq managementNotesAll Spring Boot applications require already running Config Server for startup. But we can start all containers simultaneously because of fail-fast Spring Boot property and restart: always docker-compose option. That means all dependent containers will try to restart until Config Server will be up and running.Also, Service Discovery mechanism needs some time after all applications startup. Any service is not available for discovery by clients until the instance, the Eureka server and the client all have the same metadata in their local cache, so it could take 3 hearbeats. Default hearbeat period is 30 seconds. Read more

5 Benefits of Android for Businesses Seeking an Enterprise Application

As per a study published on titled “Ten enterprise mobility statistics that may surprise you,” by 2015 the number of mobile workers will surpass 1.3 billion globally. Further, as per a mobility survey by CIONET in 2013, Apple ruled the roost at 65% for enterprise application development, Android was a close second with 55% market share. We elaborate here on the top 5 Android app development benefits for businesses seeking an enterprise application.Low InvestmentAndroid is an open-source platform and the software development kit (SDK) is freely available to developers. Further, being a Java-based platform, it is easy to master and execute. There are three stages to development on Android:Application developmentApp testingDeployment to Android App StoreAlso, with Material Design, Android app developers can add intricate details at a very low cost, giving the best ROI.BYOD PreferenceFigure 1: Source: IDC, Aug, 2015 ( the pie diagram above, the market share of Android becomes quite evident. For companies that are adopting bring your own device (BYOD) policy, it is feasible to opt for Android as the enterprise app development platform because Android is available on a wider variety of devices to users of all economic groups.Easy Customization Android offers versatility with easy customization options, thus enabling developers to create applications with diverse functionalities. Whether it is complex technical customization or web application integration, Android provides ample space for executing customizations. The platform is designed to accommodate the varying requirements of business. It offers flexibility to integrate communication tools, data management functions, and multimedia tools with easy updates.Security and DistributionGoogle rolled out major security fixes in 2012 across the Android platform, making it a highly secure platform. It further pushed an address space layout customization making it extremely difficult for malware to locate data structure for executing codes. Further, an automated system pushes periodic notifications to users to decrypt their devices. For distribution, Android apps can be marketed via various marketing channels and can be easily found in the marketplace.Wearable DevicesWearable devices are fast gaining traction amongst businesses for the quick communication that can be pushed via smartwatch notifications. As per statistics provided on, 54% of enterprises already have a bring your own wearable (BYOW) policy, and 40% are planning to adopt it soon.If your company is designing its mobile strategy and considering a single stable platform to start development with, Android app development is a feasible option. The platform gives width for the applications to grow and expand as per the needs of the company with easy feature integration.The industry average to develop and launch an application on Android platform is 8 to 18 weeks based on a study by If you want to implement a mobile strategy in the shortest span, Android will be the most recommended platform for its market perpetuation and ease in development.Related Refcard:Code Gems for Android Developers Read more

Older Post