Getting Started with Container and Cloud-based Development
Starting Development of Container and Cloud-based Applications Using Red Hat CodeReady Studio
Levi Valeeva
levi@redhat.comSupriya Takkhi
sbharadw@redhat.comYana Hontyk
yhontyk@redhat.comdevtools-docs@redhat.com
Abstract
Chapter 1. Developing using containers and the cloud
1.1. Using Red Hat CodeReady Containers tooling in CodeReady Studio
Red Hat CodeReady Containers (CRC) brings a minimal OpenShift 4 cluster to your local computer. This cluster provides a minimal environment for development and testing purposes. It is mainly targeted at running on developers' desktops. For other use cases, such as headless, multi-developer or team-based setups, use of the full-fledged OpenShift installer is recommended.
For a more in-depth introduction to OpenShift, see OpenShift documentation.
Prerequisites
- Download the latest release of CodeReady Containers and the pull secret.
Extract the CRC file.
For more information on how to install and set up CRC, see the Installation chapter of the Getting started with CodeReady Containers Guide.
1.1.1. Downloading and installing Red Hat CodeReady Containers in CodeReady Studio
The following section describes how to set up CodeReady Containers in CodeReady Studio. The section assumes you completed the steps listed in the prerequisites section for this chapter.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Server in the search field.
- Select Servers.
Click Open.
The Servers view appears.

Right-click any area in the Servers view.

Click New → Server.
The Define a New Server window appears.

- Select CodeReady Containers 1.0+.
Click Next.
The CodeReady Containers window appears.

- Click Browse to locate the CRC binary.
- Click Browse to locate the CRC Pull Secret File.
- Click Finish.
Your newly added CodeReady Containers 1.0+ server adapter is now listed in the Servers view.

1.1.2. Using the OpenShift Container Platform tooling
The following section describes how to use OpenShift Containers in CodeReady Studio.
Prerequisites
Set up and configure the CRC server adapter.
For more information, see Section 1.1.1, “Downloading and installing Red Hat CodeReady Containers in CodeReady Studio”.
Procedure
- Start CodeReady Studio.
Start the CRC server adapter.

Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Press Ctrl+N.
The Select a wizard window appears.

- Enter OpenShift in the search field.
- Select OpenShift Application.
Click Next.
The Sign in to OpenShift window appears.

Click Next.
The Create OpenShift Project window appears.
- Name your project.
Click Finish.
The Select template window appears.

- Select the template.
Click Next.
The Build Configuration window appears.

- Ensure that the build configurations are correct.
- Click Finish.
Your newly created OpenShift application project is now listed in the OpenShift Explorer view.

Additional resources
- For more information on how to perform additional tasks with the OpenShift Container Platform projects and application, see Developing for the Cloud with OpenShift.
1.2. Using Red Hat Container Development Kit tooling in CodeReady Studio
Red Hat Container Development Kit (CDK) is a pre-built container development environment based on Red Hat Enterprise Linux (RHEL). CDK helps you get started with developing container-based applications quickly. You can easily set up CDK within CodeReady Studio.
1.2.1. Installing Container Development Kit in CodeReady Studio
The following section describes how to install CDK from within CodeReady Studio.
Prerequisites
Ensure that the Hypervisor is installed and configured on your system:
- VirtualBox, Linux KVM/libvirt (Linux)
- xhyve (macOS)
- Hyper-V (Windows)
Ensure that hardware virtualization is enabled on your system.
For more information, see Setting Up the Virtualization Environment
Ensure that you have a Red Hat Developer account.
For a new account, visit https://developers.redhat.com/.
For more information on CDK, see the Red Hat Container Development Kit Getting Started Guide.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Server in the search field.
- Select Servers.
Click Open.
The Servers view appears.

Right-click any area in the Servers view.

Click New → Server.
The Define a New Server window appears.

- Select Red Hat Container Development Kit 3.2+.
Click Next.
The Red Hat Container Development Environment window appears.

Click Download and install runtime.
The Download Runtimes window appears.

- Select a Red Hat CDK version.
- Click Next.
- Ensure that your sign-on credentials for access.redhat.com are correct.
- Click Next.
- Review and accept the license agreement and click Next.
Select the installation folder and click Finish.
Note that the process of downloading and installing the runtime might take some time to complete.
Click Finish.
Your newly created Container Development Environment 3.2+ server is now listed in the Servers view.

Right-click CDK server adapter → Start.
NoteIn case you did not set up CDK prior to starting the server adapter, you will see a warning: CDK has not been properly initialized!.

Follow the on-screen instructions to initialize CDK.
1.2.2. Using Docker tooling
After starting the CDK server in the IDE, you can follow one of the two container development workflows to use the Docker tooling.
1.2.2.1. Creating a Dockerfile
Prerequisites
Set up and configure the CDK server adapter.
For more information, see Section 1.2.1, “Installing Container Development Kit in CodeReady Studio”.
Procedure
- Start CodeReady Studio.
Start the CDK server adapter.

Press Ctrl+N.
The Select a wizard window appears.

- Enter Java Project in the search field.
- Select Java Project.
Click Next.
The New Java Project window appears.

- Name your project.
- Select the location for your project.
Click Finish.
Your newly created Java project is now listed in the CodeReady Studio view.
Right-click your Java project → New → File.

The Create New File window appears.

- Select the parent folder.
- Name your file.
Click Finish.
Your newly created file is now displayed in the CodeReady Studio editor.
Paste the following content into your newly created file:
# Use latest jboss/base-jdk:8 image as the base FROM jboss/base-jdk:8 # Set the WILDFLY_VERSION env variable ENV WILDFLY_VERSION 10.1.0.Final ENV WILDFLY_SHA1 9ee3c0255e2e6007d502223916cefad2a1a5e333 ENV JBOSS_HOME /opt/jboss/wildfly USER root # Add the WildFly distribution to /opt, and make wildfly the owner of the extracted tar content # Make sure the distribution is available from a well-known place RUN cd $HOME \ && curl -O https://download.jboss.org/wildfly/$WILDFLY_VERSION/wildfly-$WILDFLY_VERSION.tar.gz \ && sha1sum wildfly-$WILDFLY_VERSION.tar.gz | grep $WILDFLY_SHA1 \ && tar xf wildfly-$WILDFLY_VERSION.tar.gz \ && mv $HOME/wildfly-$WILDFLY_VERSION $JBOSS_HOME \ && rm wildfly-$WILDFLY_VERSION.tar.gz \ && chown -R jboss:0 ${JBOSS_HOME} \ && chmod -R g+rw ${JBOSS_HOME} # Ensure signals are forwarded to the JVM process correctly for graceful shutdown ENV LAUNCH_JBOSS_IN_BACKGROUND true USER jboss # Expose the ports we're interested in EXPOSE 8080 # Set the default command to run on boot # This will boot WildFly in the standalone mode and bind to all interface CMD ["/opt/jboss/wildfly/bin/standalone.sh", "-b", "0.0.0.0"]- Press Ctrl+S to save the changes.
Additional resources
- For more information about Dockerfiles, see Dockerfile reference.
1.2.2.2. Building the Docker image Using the Container Development Environment
Prerequisites
Set up and configure the CDK server adapter.
For more information, see Section 1.2.1, “Installing Container Development Kit in CodeReady Studio”.
Create a Java project and a Docrefile.
For more information, see Section 1.2.2.1, “Creating a Dockerfile”
Procedure
- Start CodeReady Studio.
Start the CDK server adapter.

- Expand your Java project.
Right-click Dockerfile → Run as → Docker Image Build.

The Docker Image Build Configuration window appears.

- Select your Container Development Environment server adapter as your connection.
- Name your image.
- Click OK.
The Console view appears displaying the docker image building process.
1.2.2.3. Additional resources
- For more information about the basics of Docker Tooling, see Using Docker Tooling in CodeReady Studio.
1.2.3. Using the OpenShift Container Platform tooling
The following section describes how to use OpenShift Containers in CodeReady Studio.
Prerequisites
Set up and configure the CRC server adapter.
For more information, see Section 1.1.1, “Downloading and installing Red Hat CodeReady Containers in CodeReady Studio”.
Procedure
- Start CodeReady Studio.
Start the CRC server adapter.

Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Press Ctrl+N.
The Select a wizard window appears.

- Enter OpenShift in the search field.
- Select OpenShift Application.
Click Next.
The Sign in to OpenShift window appears.

Click Next.
The Create OpenShift Project window appears.
- Name your project.
Click Finish.
The Select template window appears.

- Select the template.
Click Next.
The Build Configuration window appears.

- Ensure that the build configurations are correct.
- Click Finish.
Your newly created OpenShift application project is now listed in the OpenShift Explorer view.

Additional resources
- For more information on how to perform additional tasks with the OpenShift Container Platform projects and application, see Developing for the Cloud with OpenShift.
1.2.4. Additional resources
- For more information on how to perform tasks using the OpenShift Container Platform tooling, see Developing for the Cloud with OpenShift 4.
- For more information on how to use OpenShift in CodeReady Studio, see OpenShift basics in CodeReady Studio
Chapter 2. Developing for the Cloud with OpenShift
2.1. Creating an OpenShift Container Platform application in CodeReady Studio
Using the OpenShift Container Platform tooling you can create, import, and modify OpenShift Container Platform applications.
2.1.1. Creating a new OpenShift Container Platform connection
You must create an OpenShift connection in the OpenShift Explorer view in CodeReady Studio to use the OpenShift tooling in the IDE. An OpenShift connection connects your IDE to an OpenShift instance (based on CDK, OpenShift Online, Kubernetes, minishift). The connection is listed in the OpenShift Explorer view. You can have more than one OpenShift connection configured in the IDE.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Right-click any area in the OpenShift Explorer.

Click New → Connection.
The Sign in to OpenShift window appears.

- Paste the URL for the OpenShift server into the Server field.
Authenticate with token or login credentials.
NoteAlternatively, you can copy the Login Command from the OpenShift Container Platform web UI.
To get login credentials, click the drop-down menu in the top right corner → Copy Login Command.

- Click Finish.
Your newly added connection is now listed in the OpenShift Explorer view.
2.1.2. Creating a new OpenShift Container Platform project
You must create a project, which essentially is a namespace with additional annotations, to centrally manage the access to resources for regular users.
Prerequisites
An OpenShift Container Platform connection.
For more information on how to create a new OpenShift Container Platform connection, see Section 2.1.1, “Creating a new OpenShift Container Platform connection”.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Right-click the OpenShift Container Platform connection → New → Project.

The New OpenShift Project window appears.
- Name your project.
- Click Finish.
Your newly created OpenShift project is now listed in the OpenShift Explorer view.

2.1.3. Creating a new OpenShift Container Platform application
You can use the OpenShift Application wizard in the IDE to create OpenShift Container Platform applications from default or custom templates.
Prerequisites
An OpenShift Container Platform connection.
For more information on how to create a new OpenShift Container Platform connection, see Section 2.1.1, “Creating a new OpenShift Container Platform connection”.
An OpenShift Container Platform project.
For more information on how to create a new OpenShift Container Platform project, see Section 2.1.2, “Creating a new OpenShift Container Platform project”.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Right-click the OpenShift Container Platform connection → New → Application.

The Select template window appears.

- Select the template.
Click Next.
The Template Parameters window appears.
Click Next.
The Resource Labels window appears.

- Click Add to add labels.
Click Finish.
The Create Application Summary window appears.

Click OK.
The Import OpenShift application window appears.

- Select the Git Clone Location.
- Click Finish.
Your newly created OpenShift Container Platform application is now listed in the OpenShift Explorer view.
Additional Resources
- For more information about using and creating templates with OpenShift Container Platform, see Using templates.
2.1.4. Importing an existing OpenShift Container Platform application into the IDE
The OpenShift Explorer view in the IDE lists applications associated with your OpenShift Container Platform accounts. You can import the source code for these applications individually into the IDE using the Import OpenShift Application wizard. After the application is imported, you can easily modify the application source code, build the application, and view it in a web browser.
Prerequisites
-
The application that you are importing to the IDE has its source specified in the
build configfile. An OpenShift Container Platform connection.
For more information on how to create a new OpenShift Container Platform connection, see Section 2.1.1, “Creating a new OpenShift Container Platform connection”.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
Right-click your OpenShift Container Platform connection → Import OpenShift Application.

The Select Build Config window appears.

- Select the application to import.
Click Next.
The Import OpenShift application window appears.

- Select the Git Clone Location.
- Click Finish.
Your newly imported OpenShift Container Platform application is now listed in the OpenShift Explorer view.
2.1.5. Deploying an application using the server adapter
The server adapter enables you to publish the changes that you made in your workspace project to the running OpenShift application on the OpenShift instance. It enables incremental deployment of applications directly into the deployed pods on OpenShift. You can use the server adapter to push changes in your application directly to the running OpenShift application without committing the source code to the Git repository.
Prerequisites
An OpenShift Container Platform connection.
For more information on how to create a new OpenShift Container Platform connection, see Section 2.1.1, “Creating a new OpenShift Container Platform connection”.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
- Expand the OpenShift Container Platform connection.
Right-click your application → Server Adapter.

The Server Settings window appears.

- Click Finish.
The Servers view appears, starting your server adapter.
To open your application in a browser, right-click application → Show In → Web Browser.

The CodeReady Studio built-in web browser opens, displaying your application.
2.1.6. Deleting an OpenShift Container Platform project
You may choose to delete a project from the workspace for a fresh start in project development or after you have concluded development in a project. When you delete a project, all the resources associated with the project are deleted.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
- Expand the OpenShift Container Platform connection.
Right-click your project → Delete.

The Delete OpenShift Resource window appears.
- Click OK.
Your project is now deleted.
2.2. Setting up and remotely monitoring an OpenShift Container Platform application
The IDE allows users to set up a connection to a remote instance of OpenShift Container Platform and then use logs (application logs and build logs) to troubleshoot and monitor running applications.
2.2.1. Setting up OpenShift Client Binaries
Prerequisites
Before setting up port forwarding or streaming application and build logs, it is mandatory to set up OpenShift Client Binaries.
Procedure
- Start CodeReady Studio.
Click Window → Preferences.
The Preferences window appears.

- Enter OpenShift in the search field.
- Select OpenShift.
-
Click Browse to locate the
ocexecutable. - Click Apply and Close.
OpenShift Client Binaries are now set up.
2.2.2. Setting up Port Forwarding
Using the Application Port Forwarding window, you can connect the local ports to their remote counterparts to access data or debug the application. Port forwarding automatically stops due to any one of the following reasons:
- The OpenShift Container Platform connection terminates.
- The IDE shuts down.
- The workspace is changed.
Port forwarding must be enabled each time to connect to OpenShift Container Platform from the IDE.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
- Expand the OpenShift Container Platform connection.
Right-click the application → Port Forwarding.

The Port Forwarding window appears.

- Check the Find free local ports for remote ports box.
- Click Start All.
- Click OK.
The Console view appears showing the port-forwarding starting process.
2.2.3. Streaming Pod Logs
Pod logs are general logs for applications running on a remote OpenShift Container Platform instance. The streaming application logs feature in the IDE is used to monitor applications and use the previous pod log to troubleshoot if the application fails or returns errors.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
- Expand the OpenShift Container Platform connection.
Right-click the application → Port Log.

The Console view appears displaying the Pod Log.
2.2.4. Streaming Build Logs
Build logs are logs that document changes to applications running on a remote OpenShift Container Platform instance. The streaming build logs feature in the IDE is used to view the progress of the application build process and to debug the application.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter OpenShift in the search field.
- Select OpenShift Explorer.
Click Open.
The OpenShift Explorer view appears.
- Expand the OpenShift Container Platform connection.
Right-click the application → Build Log.

The Console view appears displaying the Build Log.
2.3. Additional resources
- For more information on OpenShift Application Explorer, see Getting started with CodeReady Studio Tools.
Chapter 3. Developing with Docker
Prerequisites
Docker installed on your system.
For more information on how to install Docker, see Get Docker.
You have obtained the Docker ID.
For more information on how to get a Docker ID, see Register for a Docker ID.
3.1. Managing Docker connections
3.1.1. Setting up a Docker account in CodeReady Studio
The following section describes how to set up a Docker account in CodeReady Studio. The section assumes you completed the steps listed in the prerequisites section of this chapter.
Procedure
- Start CodeReady Studio.
Click Window → Preferences.
The Preferences window appears.

- Enter Registry Accounts in the search field.
- Select Registry Accounts.
Click Add.
The New Registry Account window appears.

- Enter the Server Address for the Docker hub.
- Enter your Doker ID as the Username.
- Enter the email associated with your Docker account.
- Enter your password.
- Click OK.
- Click Apply and Close.
3.1.2. Testing the Docker connection
Prerequisites
You have up Docker account set up in CodeReady Studio.
For more information on how to set up a Docker account in CodeReady Studio, see Section 3.1.1, “Setting up a Docker account in CodeReady Studio”
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Explorer.
Click Open.
The Docker Explorer view appears.

Right-click Docker socket → Edit.

The Edit Docker Connection window appears.

Click Test Connection.
If the connection is configured correctly, a window stating that the Ping succeeded! appears.
- Click OK.
- Click Finish.
3.1.3. Editing the Docker connection
Prerequisites
You have a Docker account set up in CodeReady Studio.
For more information on how to set up a Docker account in CodeReady Studio, see Section 3.1.1, “Setting up a Docker account in CodeReady Studio”
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Explorer.
Click Open.
The Docker Explorer view appears.

Right-click Docker socket → Edit.

The Edit Docker Connection window appears.

- Click Browse in Unix socket Location field to locate a new socket or check the TCP Connection option and add the URI.
- Click Finish.
3.2. Managing Docker images
3.2.1. Pulling Docker images
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Explorer.
Click Open.
The Docker Explorer view appears.

- Expand Docker socket folder.
Right-click Images → Pull.

The Pull Image window appears.

Click Search.
The Search the Docker Registry for images window appears.

- Enter the image name in the search field.
Click Next.
The Choose a tag for the selected image window appears.

- Choose a tag for your image.
Click Finish.
The Search the Docker Registry for images window appears.

- Click Finish.
Your new Docker image is now listed in the Docker Explorer view.

3.2.2. Pushing Docker images
Before pushing a Docker image you must tag it. The following section describes how to tag and push a Docker image in CodeReady Studio.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Explorer.
Click Open.
The Docker Explorer view appears.

- Expand Docker socket → Images.
- Right-click the image you want to tag.
Click Add tag.

The Tag Image window appears.
Enter the tag in the New Tag field.
The tag should be in the form of
username/image_name:tag_name, whereusernameis your Docker ID on https://hub.docker.com,image_nameis the name of your image, andtag_nameis the version of the image.
- Click Finish.
Right-click the tagged image → Push.

The Push image to Registry window appears.

- Select the Registry Account that starts with your Docker ID.
- Click Finish.
After you push the image it appears in the Docker Cloud. This image is then available for other developers to use.
3.2.3. Running Docker images
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Explorer.
Click Open.
The Docker Explorer view appears.

- Expand Docker socket → Images.
- Right-click images you want to run.
Click Run.

The Docker Container settings window appears.

- Name the container.
- Clear the Publish all exposed ports to random ports on the host interfaces check box.
-
Check the box for
8080port. Click Finish.
The Console view appears showing the process of starting the image.
In the web browser navigate to http://localhost:8080/ to see the image running.

3.2.4. Building images with Dockerfile
You can build an image or create one by modifying an existing image. Typically, this involves installing new packages. The specification of the new Docker image is done via a the Dockerfile
Prerequisites
Dockerfile created on your local machine.
For more information on how to create a Dockerfile, see Section 1.2.2.1, “Creating a Dockerfile”.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker in the search field.
- Select Docker Images.
Click Open.
The Docker Images view appears.

Click the Build Image icon.

The Build a Docker Image window appears.

-
Name the image in the format of
repo/name:version. - Click Browse to locate the Dockerfile.
- Click Finish.
The Console view appears displaying the build process.
3.3. Managing Docker Containers
Docker containers are isolated processes that are based on Docker images. Once created, users can stop, start, pause, unpause, kill, or remove the containers, as well as read their logs.
The following section describes how to manage Docker containers in CodeReady Studio.
Procedure
- Start CodeReady Studio.
Click Window → Show View → Other.
The Show View window appears.

- Enter Docker into the search field.
- Select Docker Containers.
Click Open.
The Docker Containers view appears.

You can start, pause, unpause, stop, kill, restart, remove, or refresh the containers by using the panel.
