Docker Assignment– 1
Docker Core Concepts
Basic Questions
- Install Docker on a Linux system using the package manager and verify installation.
- Install Docker on Windows using Docker Desktop and verify installation.
- Install Docker on Mac using Docker Desktop and verify installation.
- Run the hello-world container to confirm Docker is working.
- Run an nginx container in detached mode.
- List all running containers using docker ps.
- List all containers (running and stopped) using docker ps -a.
- Stop a running container and verify it is no longer running.
- Start a stopped container and verify it is running again.
- Remove a stopped container.
- Download an image from Docker Hub using docker pull.
- List all images available locally.
- Inspect an image using docker inspect and note its layers.
- Inspect a running container using docker inspect.
- View logs of a running container.
- Run a container and use docker exec to open a shell inside it.
- Run multiple nginx containers with different names.
- Remove an unused image from your system.
- Explain the difference between Docker images and containers by creating both.
- Create a simple text note explaining Docker architecture: Client, Daemon, Registry, and Objects.
Intermediate Questions
- Pull the latest ubuntu image and run it interactively with a shell.
- Run an alpine container and execute echo “Hello from Alpine”.
- Start two containers from the same image and verify they are independent.
- Run a container, stop it, and restart it using the same container ID.
- Run a container with a custom name and check its logs.
- Use docker exec to create a new file inside a running container.
- Use docker cp to copy a file from host to a running container.
- Use docker cp to copy a file from container back to host.
- Create three nginx containers and map each to a different host port.
- Check logs of multiple containers simultaneously.
- Inspect a container and print only its IP address using docker inspect.
- Inspect an image and print only its size using docker inspect.
- Tag an image with a custom name and version.
- Remove multiple containers in a single command.
- Remove multiple images in a single command.
- Run a container in interactive mode, install a package, and check changes.
- View resource usage of containers using docker stats.
- Rename a running container and verify the new name.
- Save an image to a .tar file and then load it back.
- Push a pulled image to your Docker Hub account (requires login).
Advanced Questions
- Write a shell script to install Docker automatically on Linux.
- Create and run five containers of nginx, each mapped to different ports, and verify access in browser.
- Create a container, exec into it, install curl, and test connectivity from inside.
- Run a container with environment variables set and verify them inside.
- Use docker inspect with a filter to show only environment variables of a container.
- Run a container with limited CPU and memory resources.
- Run a container in detached mode and reconnect to it using docker exec.
- Pull a private image from a private registry after logging in.
- Compare image vs container: create an image, run a container, modify it, and commit changes.
- Document and demonstrate the entire Docker workflow: pull image → run container → exec → logs → stop/start → remove.