INTRODUCTION
Containerization has transformed software development, deployment, and management. Docker, a leading containerization platform, stands out for its simplicity and efficiency. This hands-on lab will guide you through the basics of Docker, empowering you to leverage containerized applications with confidence.
Lab 1: Installing Docker
-
Install Docker:
- Download Docker Desktop from the official website.
- Follow the installation instructions for your operating system.
-
Verify Installation:
- Open a terminal or command prompt and run:
docker --version
docker-compose --version
This confirms Docker is installed and ready to use.
Lab 2: Running Your First Container
Step 1: Get the Sample Application
- Clone the sample application repository:
git clone https://github.com/docker/welcome-to-docker
Alternatively, download the repository manually.
Step 2: Explore the Dockerfile
A Dockerfile defines the contents of a container. Open the Dockerfile in your project folder to understand its structure.
Step 3: Build Your First Image
- Build the Docker image:
docker build -t welcome-to-docker .
The -t
flag tags the image with a name (welcome-to-docker).
The .
specifies the location of the Dockerfile.
Step 4: Run Your Container
1.Use Docker Desktop to run the container:
- Go to the Images tab, select your image, and click Run.
2.Set the
Host Port
to8080
.
Step 5: View the Frontend
Access the running container via Docker Desktop or navigate to https://docs.docker.com/get-started/introduction/ in your browser.
Step 6: Stop Your Container
Stop the container in Docker Desktop by selecting the Stop icon in the Containers tab.
Summary
This article walked you through building and running your first Docker container. You also learned how to use Docker Desktop to manage containers and images.
Reference
For more advanced use cases, explore images on Docker Hub and refer to the official Docker documentation.
Top comments (0)