ℹ️ Select 'Choose Exercise', or randomize 'Next Random Exercise' in selected language.

Choose Exercise:
Timer 00:00
WPM --
Score --
Acc --
Correct chars --

Dockerfile: Basic Package Installation

Dockerfile

Goal -- WPM

Ready
Exercise Algorithm Area
1FROM ubuntu:latest
2
3RUN apt-get update && \
4apt-get install -y --no-install-recommends \
5curl \
6wget \
7git
8
9RUN rm -rf /var/lib/apt/lists/*
Algorithm description viewbox

Dockerfile: Basic Package Installation

Algorithm description:

This Dockerfile demonstrates the basic process of installing essential command-line utilities within an Ubuntu-based container image. It uses the `apt-get` package manager to fetch and install `curl`, `wget`, and `git`. The `rm -rf` command cleans up package lists to reduce image size.

Algorithm explanation:

The `RUN` instruction executes commands in a new layer on top of the current image. `apt-get update` refreshes the package index. `apt-get install -y` installs packages non-interactively. `--no-install-recommends` avoids installing optional dependencies, keeping the image lean. Combining commands with `&& \` allows them to run in a single layer, optimizing image size and build speed. Cleaning up `apt` lists afterward is a common optimization to reduce the final image size. The time complexity for package installation is dependent on the network speed and the size of the packages being installed, typically O(N) where N is the total size of downloaded packages. Space complexity is also O(N) for storing the downloaded packages and their dependencies.

Pseudocode:

1. Start with a base Ubuntu image.
2. Update the package list.
3. Install curl, wget, and git non-interactively.
4. Clean up the apt cache.