0% found this document useful (0 votes)
18 views

docker_practice_tasks

Uploaded by

Cojjo Xenon
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views

docker_practice_tasks

Uploaded by

Cojjo Xenon
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Docker & Docker Compose Practice Tasks

BEGINNER
1. Install Docker and Run Your First Container:
- Install Docker and run `hello-world` to confirm it's working.
- Try running a basic container like `docker run alpine echo "Hello, Docker!"`.

2. Run a Web Server Container:


- Use Docker to pull and run an NGINX container.
- Expose it on your local machine at port 8080 and access the default NGINX
page.

3. Explore Docker Commands:


- Use commands like `docker ps`, `docker images`, `docker stop`, and `docker rm`
to manage containers.
- Inspect container details with `docker inspect` and `docker logs`.

4. Create a Simple Dockerfile:


- Write a Dockerfile for a simple application (e.g., a Python script or Node.js
app).
- Build the Docker image with `docker build` and run it.

5. Persist Data with Volumes:


- Run a container (like MySQL) and attach a volume for persistent data storage.
- Inspect the volume and verify the data remains even after stopping the
container.

INTERMEDIATE
6. Connect Containers Using Docker Networks:
- Create two containers (e.g., a web app and a database) and connect them via a
Docker network.
- Test communication between the containers by pinging from one to the other.

7. Use Environment Variables for Configuration:


- Use environment variables in a Dockerfile and `docker run` command.
- Create a container that reads configurations (like database credentials) from
environment variables.

8. Build a Multi-Stage Dockerfile:


- Create a multi-stage Dockerfile to build and run an application (e.g., compile
a React app in one stage and serve it with NGINX in another).
- Observe how this reduces the final image size.

9. Create a Basic Docker Compose File:


- Write a `docker-compose.yml` file to define a multi-container application
(e.g., a web server and a database).
- Use `docker-compose up` to start all services and `docker-compose down` to
stop and remove them.

10. Manage Application Secrets:


- Use environment files (`.env`) with Docker Compose to securely manage
sensitive information like passwords.
- Test the setup by configuring your application to read sensitive data from the
environment.

ADVANCED
11. Create a Custom Docker Network with Compose:
- Define multiple services (e.g., a frontend, backend, and database) in a Docker
Compose file.
- Create a custom bridge network for these services and verify they can
communicate only within the network.

12. Implement Health Checks:


- Add health checks to your `docker-compose.yml` for each service.
- Configure a service to wait until another service (e.g., a database) is
healthy before starting.

13. Automate Builds with Docker Compose:


- Set up Docker Compose to build images automatically from Dockerfiles.
- Define build contexts for each service and use `docker-compose up --build` to
start everything with the latest changes.

14. Use Bind Mounts for Development:


- Set up a local directory as a bind mount in a container to allow code editing
on the host machine while running it in a container.
- Test this setup by modifying code on your machine and observing changes in the
container in real-time.

15. Deploy a Dockerized Application to a Cloud Service:


- Push your Docker image to Docker Hub.
- Deploy it to a cloud service (e.g., AWS ECS, Google Cloud Run, or Azure
Container Instances).
- Alternatively, use Docker Compose to deploy on a cloud-based Docker Swarm or
Kubernetes cluster.

You might also like