Community Articles
Find and share helpful community-sourced technical articles
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.
Labels (1)

Objective

The Hortonworks Sandbox for HDP 2.5 now uses Docker containers, even the VirtualBox version. The process for exposing extra ports on older versions of the sandbox was as simple as setting up additional port forwarding rules in VirtualBox. The new container version of the sandbox requires additional steps; you have to do more than just setup port forwarding rules in VirtualBox.

This tutorial will guide you through the process of adding additional ports to the VirtualBox version of the HDP 2.5 sandbox.

Prerequisites

  • You should have already downloaded and installed the VirtualBox version of the Hortonworks Sandbox for HDP 2.5 Hortonworks Sandbox

Scope

  • Mac OS X 10.11.6 (El Capitan)
  • VirtualBox 5.1.6
  • HDP 2.5 VirtualBox Sandbox

Steps

Startup the Sandbox VM

Startup your HDP sandbox. It should be called Hortonworks Docker Sandbox within VirtualBox. You should see something similar to this:

9329-virtualbox-1.png

You can start the sandbox by either double-clicking on the virtual machine or by selecting the virtual machine and clicking on the start icon in the menu. Once the virtual machine is started, you should see something similar to this:

9330-virtualbox-2.png

NOTE: It may take several minutes for the virtual machine to start.

Login to the Sandbox VM

We need to login to the VM that runs the sandbox container. If you use the standard ssh -p 2222 root@localhost, you will actually login to the sandbox container, not the sandbox VM. You can login to the sandbox VM using ssh -p 2122 root@localhost.

You can also login to the sandbox VM directly using the VirtualBox VM window by following the instructions on the VM window. On the Mac you click in the VM window and press the Alt/Option + F5 keys. You should see something like this:

9331-virtualbox-3.png

The username is root and the password is hadoop.

Disable sandbox.service

The sandbox Docker container is set to autostart when the VM starts. I've run into issues trying to top the Docker container. So we'll use a workaround to temporarily disable the sandbox.service. The sandbox VM is based on CentOS 7 and uses systemd.

systemctl disable sandbox.service

Reboot the VM

Now we need to reboot the VM so we can get it started without the sandbox container running. You can do this easily using the init command.

init 6

The VM should reboot.

Modify sandbox start script

After the VM reboots, login again using the steps provided above. The sandbox start script is located at /root/start_scripts/start_sandbox.sh. This script has the docker run command which creates or starts the Docker container. We need to edit this script to add our additional ports. For the purposes of this tutorial, we'll add port 8440 which is used by Ambari agents to talk to Ambari server.

vi /root/start_scripts/start_sandbox.sh

Scroll down until you see:

-p 2222:22 sandbox /usr/sbin/sshd -D

We need to add a line after the last port entry. Modify the script so it now looks like this:

-p 2222:22 -p 8440:8440 sandbox /usr/sbin/sshd -D

Now save the file

Press ESC key
:wq!

Delete existing sandbox container

Since we booted up the VM at least once, the sandbox container will already exist. The startup script will not and cannot update an existing container to add another port. So we need to remove the existing sandbox container. The startup script will create a new container with the added ports. Remember with Docker that a Docker image is like a blueprint to the building and a Docker container is the building created from the blueprint. We will delete the container, not the image.

docker rm sandbox

NOTE: This will remove any changes you've made to your Docker container via Ambari, etc. If you want to save any changes you've made, you can update the base sandbox Docker image using docker commit. To update the base sandbox image with any configuration changes you've done use docker commit sandbox sandbox.

Enable sandbox.service

Now we need to enable the sandbox service so it auto starts when the VM boots up.

systemctl enable sandbox.service

Reboot the VM

Now it's time to reboot the VM. As before, we'll use the init command

init 6

Verify new ports

After the VM reboots, login again using the steps provided above. We are going to show the running Docker container using the docker ps command.

docker ps

You should notice the standard Docker output from that command. Look for the port 8440. You should see it in the list. You should see something similar to this:

9332-virtualbox-4.png

NOTE: We added the port to the end of the startup script. However, the port will not be displayed at the end of the list. The port will be somewhere in the middle of the list of ports.

Update VirtualBox VM ports

Now we need to update the forwarded ports configuration for our VirtualBox VM. Using the VirtualBox user interface, right-click on the Hortonworks Docker Sandbox to display the menu. You should see something similar to this:

9333-virtualbox-5.png

Now click the Settings menu option. You should see something similar to this:

9334-virtualbox-6.png

Now click on the Network menu icon. You should see something similar to this:

9335-virtualbox-7.png

Now click the Advanced dropdown menu near the bottom. You should see something similar to this:

9336-virtualbox-8.png

Now click the Port Forwarding button. You should see something similar to this:

9337-virtualbox-9.png

Now click the + icon near the upper right to add another port forwarding rule. You should see something similar to this:

9338-virtualbox-10.png

Now add an entry with the following info:

9339-virtualbox-11.png

Click the blue OK button. Click the OK button. The settings should be saved.

Now port 8440 should be accessible on your computer which is forwarded to 8440 on the VirtualBox VM which is then passed to the Docker container.

Review

If you successfully followed along with this tutorial, we were able modify the Docker startup script for our sandbox container with the VirtualBox VM to add another port. After removing the Docker container and restarting the VM, a new Docker container was created with our additional port.

12,310 Views
Comments
Not applicable

hello, thank you for this post. I still have issues though. Does docker rm sandbox removes files from my directories?

New Contributor

Is this workflow similar for HDF 3.1 Sandbox? If not, kindly let us know the changes.

Don't have an account?
Coming from Hortonworks? Activate your account here
Version history
Revision #:
2 of 2
Last update:
‎08-17-2019 08:19 AM
Updated by:
 
Contributors
Top Kudoed Authors