Chapter 1. Introducing Red Hat Container Development Kit
Red Hat Container Development Kit is a platform for developing containerized applications — it is a set of tools that enables developers to quickly and easily set up an environment for developing and testing containerized applications on the Red Hat Enterprise Linux platform.
- Container Development Kit provides a personal Container Development Environment you can install on your own laptop, desktop, or server system. The Container Development Environment is provided in the form of a Red Hat Enterprise Linux virtual machine. The Container Development Environment itself can also be installed in a virtual machine.
- Container Development Kit includes the same container-development and run-time tools used to create and deploy containers for large data centers.
- Container Development Kit offers an easy installation method that results in virtual machines created from pre-configured Vagrant boxes and Vagrantfiles running on your local system.
- Container Development Kit is available for Microsoft Windows, Mac OS X, and Linux operating systems, thus allowing developers to use their favorite platform while producing applications ready to be deployed in the Red Hat Enterprise Linux ecosystem.
Container Development Kit is a part of the Red Hat Developers program, which provides tools, resources, and support for developers who wish to utilize Red Hat solutions and products to create applications, both locally and in the cloud. For additional information and to register to become a part of the program, visit developers.redhat.com.
1.1. Understanding Container Development Kit Documentation
- The Red Hat Container Development Kit 2.2 Release Notes and Known Issues contains information about the current release of the product as well as a list of known problems that users may encounter when using it.
- The Red Hat Container Development Kit 2.2 Installation Guide guide contains instructions for installing the Container Development Environment provided by Red Hat Container Development Kit on your chosen system.
- The Container Development Kit Getting Started Guide contains instructions on how to start using the Container Development Environment to develop Red Hat Enterprise Linux-based containers using tools and services such as OpenShift Enterprise, Docker, Eclipse, and various command-line tools.
- Report issues with Red Hat Container Development Kit or request new features using the CDK project at https://issues.jboss.org/projects/CDK.
1.2. About Containers
Containers are a form of operating-system-level virtualization, which is based on sharing the underlying host system’s kernel while providing multiple user-space instances (software containers). Containers are easier to build and initialize than hardware-level virtual machines, which makes them useful for situations where virtual environments need to be deployed rapidly or in large numbers. Applications running inside virtual software containers remain isolated from the host system.
1.3. About Container Development Kit
Container Development Kit enables the development of containers on Red Hat Enterprise Linux, regardless of what operating system you use on your development workstation. The core of the development environment is a virtualized instance of Red Hat Enterprise Linux managed by Vagrant, an open-source tool for using light-weight, portable, and consistent development environments. Vagrant is utilized to bring up a pre-built Red Hat Enterprise Linux virtual machine with the Container Development Kit software components installed. Virtual machines that are packaged for use with Vagrant are called boxes.
Once you have the Container Development Kit software components installed, you can explore Linux container development using Docker, an open-source project that automates the deployment of applications inside of software containers. Docker is built upon a number of key Linux technologies that provide the capabilities to keep containers isolated and secure while controlling resource usage. For actual deployment and orchestration of containerized applications, Container Development Kit offers OpenShift with Kubernetes, a platform as a service (PaaS) product, which can be used to maintain underlying services and scale running applications as needed.
After the installation of Container Development Kit, the technology stack that is available to you for container development is:
Layer Description | Technology |
---|---|
Your Containers | Your application running in containers |
Container management | Docker service |
Development VM | Red Hat Enterprise Linux Server 7 |
VM management | Vagrant |
Virtualization provider | Virtualbox, HyperV, or libvirt/KVM |
Host machine OS | Microsoft Windows, Mac OS X, or Red Hat Enterprise Linux 7 |
1.4. About Vagrant
Vagrant has become a de facto standard for packaging and distributing development environments that run using most of the popular virtualization platforms on Windows, Mac OS X, and Linux as well as in the cloud with plugins for OpenStack, Amazon Web Services (AWS), and other environments.
Vagrant uses a single configuration file, the Vagrantfile, to describe a development environment. Using a Vagrantfile and a virtual-machine image packaged as a Vagrant box, a single command, vagrant up
, brings up a consistent development environment that includes networking and support for folders that are shared with the host OS for moving code, data, or configuration.
Container Development Kit includes a Vagrant box with a Red Hat Enterprise Linux system that is preconfigured to provide an environment for easy container development. The supplied Vagrant box can be deployed using either VirtualBox or KVM (with libvirt) as a virtualization platform. Container Development Kit also includes two Vagrantfiles that demonstrate Vagrant provisioning, which includes setting up private networking that exposes services from the virtual machine to the host system and other configuration tasks.
The vagrant ssh
command is used to log into Vagrant boxes. The configuration details for networking and SSH keys are handled automatically by Vagrant.
1.4.1. Understanding Vagrant Configuration
Vagrant’s power for creating and distributing portable and reproducible environments derives from using a single file (Vagrantfile) to describe the target environment. A Vagrantfile defines required resources, such as virtual-machine images, networking, and provisioning steps. A separate directory containing a Vagrantfile is used for each target environment.
1.4.1.1. Managing Vagrantfiles
Vagrant commands that take action on a specific environment need to either specify the ID of the environment (if it has already been initialized) or be executed in the directory that contains the environment’s Vagrantfile. That directory forms a 'root' directory for the environment. Within this 'root' directory, Vagrant stores state information for the given environment in the .vagrant
subdirectory.
Container Development Kit includes a number of sample Vagrantfiles in separate directories with a README
file in each one. Start by changing into the directories, viewing the README
and Vagrantfile
files, and then starting the environment with the vagrant up
command.
The tilde character (~
) used in a file-system path denotes a user’s home directory on Unix-based operating systems, such as Mac OS X or Linux. Therefore, ~/.vagrant.d
on Linux or Mac OS X corresponds to %USERPROFILE%\.vagrant.d
on Windows systems.
In addition to the per-environment configuration and state directories, Vagrant uses the ~/.vagrant.d
directory to store data that applies to all Vagrant environments run by a given user. When a Vagrant box is added, or plugins are installed, they are added to ~/.vagrant.d
. That is, when you run the vagrant box add
command, the box’s Vagrantfile is installed in the per-user Vagrant directory, ~/.vagrant.d/boxes/
. Since this is stored in the user’s home directory, each user is completely independent and not able to see Vagrant boxes or plugins installed by another user.
Vagrant does not use a concept of system-wide configuration, so even if you run Vagrant as root (Administrator), it only makes changes in the root’s home directory, and these changes are not visible to regular users.
Each Vagrant box that you download or build has its own Vagrantfile, which provides basic configuration for that box. When a Vagrant box is added, the included Vagrantfile is copied into the per-user ~/.vagrant.d
directory. The settings in the box’s Vagrantfile can be overridden with the per-environment Vagrantfile.
Finally, there is per-user Vagrantfile in ~/.vagrant.d
for configuration that should be available to all of the user’s Vagrant environments. This file is not created by default.
1.4.2. Vagrant Synchronized Folders
When a box is brought up, Vagrant automatically creates a Vagrant synchronized directory using the vagrant-sshfs
plugin. This synchronized directory maps your home directory on the host into the Container Development Kit virtual machine.
For example, /home/joe/
on the host is synchronized to /home/joe/
. On Microsoft Windows, the home folder, C:\Users\joe
is mapped to /c/home/joe
within the virtual machine.
This provides a convenient and automated method to move code, data, and configuration from the host machine to your Vagrant boxes.
A number of other methods are available for sharing folders or making copies, such as rsync
, NFS, or VirtualBox shared folders. The type of synchronization used for each shared folder can be set in the definition for the shared folder in the Vagrantfile (the config.vm.synced_folder
option). Shared folder definitions may also be in the Vagrantfile that comes with a Vagrant box. This is important to remember if you are trying to completely disable shared folders or change the method used for sharing data.