Skip to content

Using the Docker image

Suraj B M edited this page Feb 9, 2024 · 2 revisions

Whether you pulled the image or built it yourselves, follow these steps to use it.

Steps

  1. Create a new container out of the image using the run command. Replace ANYNAME in the command below with any name that you can remember, preferably your SRN.
docker run -it -p 9870:9870 -p 8088:8088 -p 9864:9864 --name ANYNAME hadoop
  1. The container is created and you're faced with a prompt that looks like this: root@6aaa78189146:/#.

  2. Now, type init to initialize everything. You will be asked to enter a PC name. Enter whatever you like. Next, choose a color for your prompt and press Enter. The script stops all processes, formats namenodes, starts all processes and shows the number, which is ideally 7 or 8.

  3. Enter source ~/.bashrc to see all changes.


Using an already created container

  • If you already have a container that you used in the previous session, just type
docker start -ai CONTAINER_NAME bash

to start the container and open a terminal. Replace CONTAINER_NAME with the actual name of the container.

  • If you happen to forget the name of the container, just type docker ps -a to show names of all containers on your PC.

  • If you want to open another terminal in an already started container, type

docker exec -it CONTAINER_NAME bash

Common Errors

  • unable to find hadoop:latest locally
    You did not add an alias to the image that you pulled from Docker Hub. Check the Pulling a prebuilt Docker image page to fix it.
  • port is already allocated
    There is already another container running. Find it out using docker ps, and stop it using docker stop CONTAINER_NAME.
  • You cannot create two containers with the same name. If you want to reuse the name, delete the old container with docker rm CONTAINER_NAME and create a new container.
Clone this wiki locally