Sample Quetions
Sample Quetions
you provided. These questions will help you practice various aspects of managing
containers:
1. Container Creation:
- Create a container named `webapp` using the `nginx` image from
`registry.example.com`. Set up port forwarding so that port `8080` on the host maps
to port `80` in the container.
2. Persistent Storage:
- Create a container `database` using the `mysql` image. Mount the host
directory `/data/mysql` to `/var/lib/mysql` inside the container. Ensure that the
data persists even if the container is removed.
3. Systemd Integration:
- Create a container `myapp` from the `myapp_image` and configure a `systemd`
service named `myapp-container` to automatically start the container upon reboot
for the user `student`.
4. Logging:
- Configure a container named `log-collector` using `fluentd` image to collect
logs from `/var/log/nginx` on the host system. Mount the directory to `/mnt/logs`
inside the container.
5. Container Networking:
- Create a user-defined network named `mynetwork` and connect two containers
`frontend` and `backend` to this network using `alpine` images. Ensure that
`frontend` can communicate with `backend` using the container name.
6. **Container Updates**:
- Update the `app-container` container running the `myapp:v1` image to
`myapp:v2` while ensuring zero downtime. Describe the steps needed to achieve this.
7. **Environment Variables**:
- Create a container `webapp` using the `httpd` image. Pass the environment
variables `APP_ENV=production` and `DB_HOST=database.local` during container
creation.
8. **Resource Limiting**:
- Create a container named `resource-limited` using the `alpine` image. Limit
the container to use a maximum of `512MB` of memory and `1` CPU core.
9. **Data Backup**:
- Create a container `backup-container` using the `busybox` image. Mount the
`/var/lib/mysql` directory from the host to `/backup/mysql` inside the container
and run a daily backup script to compress the data.
Here are 10 more practice questions related to container management to help you
deepen your understanding:
### Additional Practice Questions:
1. **Network Configuration**:
- Create a `redis` container named `redis-cache` using the `redis` image.
Connect it to a user-defined network `cache-network` and verify that it is
reachable by another container named `app-server` using `alpine`.
4. **Environment Configuration**:
- Create a container named `db-container` using the `postgres` image. Pass the
environment variables `POSTGRES_USER=admin` and `POSTGRES_PASSWORD=secret` during
container creation.
5. **Volume Management**:
- Create a volume named `data-vol` and use it to create a `mysql` container that
stores its database in this volume. Verify that data persists even after the
container is removed and recreated.
6. **Container Logs**:
- Run a `nginx` container named `webserver` and access its logs using `podman
logs` or `docker logs`. Redirect the logs to a file named `webserver-logs.txt` in
the host's `/home/user/logs` directory.
8. **Bind Mounts**:
- Create a `nodejs` container named `node-app` using a `node` image and bind
mount the host directory `/home/user/node-app` to `/app` inside the container.
Ensure that changes in the host directory are reflected inside the container.
9. **Container Networking**:
- Create a bridge network named `custom-net` and run two containers, `nginx-
proxy` and `app-server`, connected to `custom-net`. Make sure `nginx-proxy` can
forward traffic to `app-server` using its container name.