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.
