Skip to content

NextGenBTS

NextGenBTS Overview

NextGenBTS is an innovative project that leverages Docker to develop a demo BTS application. This training structure provides a hands-on experience in working with Docker and implementing NextGenBTS.

The application consists of three components:

NextGenBTS

Connecting to lab

Connecting to the lab is an optional step, if you don't want to run the demo on your environment.

To connecting to the lab platform, you should have the SSH key. The key is being shared during the session. Use the below commands to connect to the lab:

chmod 400 lab.pem
ssh -i "lab.pem" -o IdentitiesOnly=yes ubuntu@<IP>

Instaructure is sharing the screen with tmux. Check the active tmux sessions using the below command:

tmux ls

A session called lab is ready to attach. You should attach to the session in read-only mode using the below command:

tmux attach-session -t lab -r

To exit the session use Ctr + b + d

Install Docker

Docker Engine is available on a variety of Linux distros, macOS, and Windows 10 through Docker Desktop, and as a static binary installation. Find your preferred operating system and follow the structure based on official Docker installation guide.

The lab platform is based on Ubuntu version. The following guides show how to install Docker on Ubuntu step-by-step. Ref: Install Docker Engine on Ubuntu

Uninstall old versions

Older versions of Docker went by the names of docker, docker.io, or docker-engine, you might also have installations of containerd or runc. Uninstall any such older versions before attempting to install a new version:

for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done

Set up the repository

Update the apt package index and install packages to allow apt to use a repository over HTTPS:

sudo apt-get update
sudo apt-get install ca-certificates curl gnupg

Add Docker’s official GPG key:

sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg

Use the following command to set up the repository:

echo \
  "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Install Docker Engine

Update the apt package index:

sudo apt-get update

Install the latest version of Docker Engine, containerd, and Docker Compose.

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin docker-compose

post-installation steps

These optional post-installation procedures shows you how to configure your Linux host machine to work better with Docker. The Docker daemon binds to a Unix socket, not a TCP port. By default it’s the root user that owns the Unix socket, and other users can only access it using sudo. The Docker daemon always runs as the root user.

If you don’t want to preface the docker command with sudo, create a Unix group called docker and add users to it. When the Docker daemon starts, it creates a Unix socket accessible by members of the docker group. On some Linux distributions, the system automatically creates this group when installing Docker Engine using a package manager. In that case, there is no need for you to manually create the group.

Create the docker group:

sudo groupadd docker

Add your user to the docker group:

sudo usermod -aG docker $USER

Reboot the system:

sudo reboot

After reboot you should follow the steps to connect to the lab and attach to the session.

We can verify the installtion by running:

docker system info

Which information does the command provide to us?

Docker provides a script to install Docker automatically: get.docker.com Run this command to install Docker automatically: curl -fsSL https://get.docker.com | sh

Setup NextGenBTS

Downloading and Setup

To download and set up the NextGenBTS project, follow these steps:

Clone the NextGenBTS Repository:

git clone https://github.com/meraj-kashi/NextGenBTS.git

Navigate to the cloned repository directory:

cd NextGenBTS/docker-compose

Run the script to deploy NextGenBTS application:

./run.sh
Verify the NextGenBTS is up and running by navihating to the below url in your browser:

http://<IP>:5000

NextGenBTS UI

Congradulations! You deployed NextGenBTS successfully!

You are being provided the usernamer and password to explore the NextGenBTS.

Docker in surface

The below section shows some basic docker commands:

Check the system info again:

docker system info

Check running containers:

docker ps

Check local Docker images:

docker image ls

OR

docker images

Run the below command to spin up the hello-world container:

docker run hello-world

Check the output and steps!

Now, check available Docker images.

Try to run an Ubuntu Docker container. (Hint: Find the image name from docker hub)

During deployment of Ubuntu container, try to use -i and -t switch. What is the best way to exit the container?

Now, re-run the command and add -d switch. Check number of running containers.

Run the below command:

docker ps -a

Why does it show more containers? Check status of containers!

Try to remove the exited containers using the below command:

docker rm

Now, try to remove a running container, what is the result of docker rm on a running container?

Before using --force option, try to stop the container.

What do you think about deleting Docker images?

Practice your knowledge

You can practice these tasks in a terminal or command prompt with Docker installed on your machine. Make sure you have Docker properly installed and configured before starting the practice scenario.

Remember to refer to Docker's official documentation for detailed information on each command and its usage. Happy learning!

Scenario1

Setting up a Web Server Container

Task 1: Pull a Docker Image

Pull the official Nginx Docker image from the Docker Hub repository using the docker pull command.

Task 2: Run a Container in Interactive Mode

Run a new Docker container using the Nginx image with the docker run command in interactive mode (-it flag). Map the container's port 80 to a port on your local machine (e.g., 8080) using the -p flag.

Task 3: Access the Web Server

Open a web browser and navigate to http://localhost:8080 to access the Nginx web server running inside the Docker container.

Task 4: Attach and Detach from a Running Container

While the container is running, detach from the container's console without stopping it using the Ctrl + P, Ctrl + Q key combination.

Task 5: Execute Commands Inside the Container

Reattach to the running container's console using the docker attach command.
Once inside the container, execute commands like ls, pwd, etc., to explore the container's filesystem.
Exit the container's console by typing exit.

Task 6: Copy Files to and from a Container

Copy a file from your local machine to the running container using the docker cp command.
Copy a file from the container to your local machine using the docker cp command.

Task 7: Stop and Start a Container

Stop the running container using the docker stop command.
Start the stopped container again using the docker start command.

Task 8: Run a Container in Detached Mode

Run a new Docker container in detached mode (-d flag) using the Nginx image.
Map the container's port 80 to a port on your local machine (e.g., 8081) using the -p flag.

Scenario2

Docker exec vs. Docker attach

Task 1: Run a Container with a Specific Name

  1. Run a new Docker container from the Ubuntu image in detached mode (-d flag).
  2. Add a specific name to the container using the --name flag (e.g., "my-container").

Task 2: View Container Processes

  1. Use the docker ps command to view the running containers.
  2. Identify the process ID (PID) of the container named "my-container".

Task 3: Execute Commands Inside the Container with docker exec

  1. Use the docker exec command to execute a command (e.g., ls -l) inside the running container named "my-container" using the container's PID.
  2. Verify that the command is executed successfully and observe the output.

Task 4: Attach to the Container Console with docker attach

  1. Use the docker attach command to attach to the running container named "my-container".
  2. Inside the attached console, execute a command (e.g., ls) and observe the output.
  3. Detach from the container's console without stopping it using the Ctrl + P, Ctrl + Q key combination.

Task 5: Delete a Container

  1. Stop the running container named "my-container" using the docker stop command.
  2. Delete the stopped container using the docker rm command, specifying the container's name or ID.

Task 6: Delete an Image

  1. List all the Docker images on your system using the docker images command.
  2. Identify the ID of the image you want to delete.
  3. Delete the image using the docker rmi command, specifying the image's ID.

Understanding the differences between docker exec and docker attach will help you work with containers more effectively. Additionally, managing containers and images is crucial for maintaining your Docker environment.

Comments