Unit-2
Unit-2
Unit-2
A Docker container can wrap a complete runtime environment that you need to quickly get
started. You do not need to install the software on your physical machine. For instance, to test
your web application on Ubuntu 16.04 with IBM® Rational® Functional Tester on the Google
Chrome browser, you do not need to install Ubuntu, Rational Functional Tester, or Chrome on
the physical machine. They can be wrapped in a Docker image and launched on various physical
machines.
Procedure
1. Download Dockerfile from Continuous Testing and also download Installation
Manager to the same folder.
Note:
2. Log in to the Ubuntu machine as a root or sudo user and point to the folder where
Dockerfile is installed.
3. To see whether Docker is running as expected, run the following commands:
Docker commands
Command Description
docker
Checks the version of docker.
version
Runs the sample hello-world image. If the command returns hello
docker run hello-
world, you are all set to start using Rational Functional Tester on
world
Docker.
Command Description
Build Builds the image
–build-arg Defines a variable that you can pass to the build command at build time.
Note: You must specify the IBM ID user name and password in the command.
Tip:
o If you have changed the file name of the Dockerfile, you must add –
f DockerfileName to the build command.
o When an image is getting created and you run the command to view all of the
images, an entry called none is listed for the in-progress image.
When you create the image for the first time, this command takes several minutes
because it installs IBM Installation Manager, Rational Functional Tester and the web
browser (Firefox, Chrome, or both). The next time onwards Docker fetches the files
from the cache and builds the image faster.
o The docker run command might fail if you did not run the command to export the
display of UI. The command to export the display of UI might differ based on the
remote client and X server that you use.
o To remove the image when you exit Docker, add –rm to the build command.
Rational Functional Tester is started. You can now record or run a test.
• Developers work on different features or bug fixes in parallel and commit their changes
to a shared version control system (e.g., Git).
• Whenever new code is committed, the CI server automatically triggers a build process.
• The CI server pulls the latest code from the repository and starts building a Docker
container.
• During the build process, the necessary dependencies, libraries, and configurations are
added to the container.
• Unit tests and other automated tests are executed within the container to verify that
the code functions correctly and meets quality standards.
• If any issues or failures occur during the build or testing phase, the CI server notifies the
development team, allowing them to fix the problems early on.
• Once the CI process is complete and all tests pass successfully, the container is
considered "ready" for deployment.
• The container image is tagged with a version number or other identifier to keep track of
different releases.
• Once the container is deployed, the software becomes accessible to users or other
systems.
• Consistency and Portability: Docker containers encapsulate the application and its
dependencies, ensuring consistent behavior across different environments. This eliminates the
"it works on my machine" problem and makes deployments more reliable.
• Isolation and Scalability: Each container runs in isolation, preventing conflicts between different
applications and allowing horizontal scaling by running multiple containers concurrently.
• Faster Feedback and Faster Releases: CI/CD automation allows for rapid feedback on code
changes, enabling developers to detect and fix issues early. It also enables faster release cycles,
as the deployment process becomes automated and streamlined.
• Rollback and Versioning: Docker container images can be tagged with version numbers, making
it easier to track and roll back to previous releases if needed.
Overall, the CI/CD pipeline in Docker helps teams to automate the software development and
deployment processes, improving collaboration, code quality, and the speed at which applications are
delivered to end-users.
- In this file, you'll define the services (containers) and their configurations.
- Define each service/container you want to run as a separate configuration block under the `services`
section.
- Specify the image or build context for each service. You can use a pre-built image from Docker Hub or
build your own Docker image.
- Configure the necessary environment variables, volumes, network settings, ports, and other
configuration options for each service.
- You can use environment variables within your Docker Compose file to manage different
configurations. Set the environment variables at runtime or use a `.env` file to store the configuration
values.
- Use these environment variables within the Docker Compose file to dynamically configure your
services.
- Open a terminal or command prompt and navigate to the directory containing the `docker-
compose.yml` file.
- Run the command `docker-compose up` to start all the services defined in the Docker Compose file.
- Docker Compose will create and manage the necessary containers based on your configurations.
- You can use additional Docker Compose commands like `docker-compose down`, `docker-compose
stop`, and `docker-compose restart` to manage the running containers.
By following these steps, you can effectively manage a multi-configuration job using Docker Compose. It
allows you to define and control multiple containers and their configurations as a unified application,
simplifying the management and deployment process.
Building application services with Docker is a popular approach to containerization and deployment.
Docker allows you to package your application and its dependencies into a standardized container,
providing consistency and portability across different environments. Here's a step-by-step guide to
building application services with Docker:
1. Define your application: Start by understanding the components of your application and how they
interact. Identify the services, dependencies, and configurations required for your application to
run successfully.
2. Write a Dockerfile: The Dockerfile is a text file that contains instructions for building a Docker
image. It specifies the base image, sets up the environment, copies application code, installs
dependencies, and configures the container. You can use various Docker commands and
instructions to achieve this.
3. Create a Docker image: Use the Docker build command to create a Docker image based on the
instructions defined in the Dockerfile. This process involves building the image layer by layer,
caching intermediate layers to speed up subsequent builds.
arduinoCopy code
4. Test the Docker image: Once the Docker image is built, you can create a Docker container from it
to test if your application runs as expected. Make sure to expose the required ports and volumes
for communication and data persistence.
arduinoCopy code
5. Push the Docker image: If you want to share your Docker image or deploy it to a remote server,
you need to push it to a container registry. Popular container registries include Docker Hub,
Amazon Elastic Container Registry (ECR), and Google Container Registry (GCR).
rubyCopy code
6. Orchestrate with Docker Compose or Kubernetes: If your application requires multiple containers
or services, you can use Docker Compose or Kubernetes to orchestrate and manage them. Docker
Compose allows you to define a multi-container application using a YAML file, while Kubernetes is
a more robust container orchestration platform.
• Kubernetes: Create Kubernetes manifests (YAML or JSON files) that describe your
application's containers, deployments, services, and other resources. Use the kubectl
command to apply these manifests to a Kubernetes cluster.
That's a high-level overview of building application services with Docker. It's important to note that
Docker is just one piece of the containerization ecosystem, and there are other tools and techniques
available depending on your specific needs.