Overview

This project documents a Docker-based workflow for processing a local copy of a website. A Python script runs inside a Docker container to discover HTML files and remove selected page elements identified by the IDs header, sidebar and footer.

The workflow covers preparing the project environment, building a Docker image, running the processing script, reviewing the reported results, accessing the output directory and stopping Docker Desktop on macOS.

Project objective

Produce a separate collection of processed HTML files while keeping the original website copy in its own input directory.

Environment

The terminal session reported the following environment:

Host operating systemmacOS
Host shellzsh
Docker version29.8.0, build 88096ef
Docker runtimeDocker Desktop
Docker builderdocker:desktop-linux
Base imagepython:3.12-slim
Python dependencybeautifulsoup4
Project directoryhtml-editor
Input directorywebsitename-copy
Processing scriptedit_html.py
Docker imagehtml-editor
Output directorywebsitename-cleaned

Project Structure

The project uses a dedicated directory for the Docker configuration, Python script, original website files and processed output.

html-editor/
├── Dockerfile
├── edit_html.py
├── websitename-copy/
└── websitename-cleaned/

The output directory was reported by the script. Its contents were not independently verified in the recorded session.

Commands and Explanations

1. Check Docker

docker --version

Checks whether Docker is installed and available in the terminal.

Observed result: Docker version 29.8.0, build 88096ef.

2. Create the project directory

mkdir html-editor
cd html-editor
  • mkdir creates the project workspace.
  • cd changes the current directory to that workspace.

3. Create or edit the Dockerfile

nano Dockerfile

Opens the Nano editor to create or edit the Dockerfile. This file defines the instructions used to build the Docker image.

The exact Dockerfile contents were not included in the supplied terminal transcript.

4. Build the Docker image

docker build -t html-editor .
  • docker build starts the image build.
  • -t html-editor assigns the image a name.
  • . uses the current directory as the build context.

Observed result: The image build completed successfully. The build output showed the python:3.12-slim base image and installation of beautifulsoup4.

5. Create or edit the Python script

nano edit_html.py

Opens the Python processing script in Nano. The script performs HTML-file discovery and cleanup.

The exact source code was not included in the transcript.

6. Inspect the project directory

ls

Lists files and folders in the current directory.

Observed entries: Dockerfile, edit_html.py and websitename-copy.

7. Run the file-discovery pass

docker run --rm -v "$(pwd):/app" html-editor python edit_html.py

Runs the Python script inside a temporary container.

  • docker run starts a container.
  • --rm removes the container after it exits.
  • -v "$(pwd):/app" mounts the current host directory at /app inside the container.
  • html-editor identifies the image.
  • python edit_html.py executes the script.

Observed result: The first recorded run reported finding 354 HTML files and printed their paths.

8. Return to the project directory and revise the script

cd ~/html-editor
nano edit_html.py

Returns to the project directory under the user's home directory and reopens the Python script for editing.

The transcript confirms another edit but does not show the precise code changes.

9. Run the cleanup pass

docker run --rm -v "$(pwd):/app" html-editor python edit_html.py

Runs the updated script in a fresh temporary container with the project directory mounted at /app.

Reported output:

  • 354 HTML files found
  • Cleanup started
  • Cleanup completed
  • 353 header elements removed
  • 353 sidebar elements removed
  • 353 footer elements removed
  • Output saved in /app/websitename-cleaned

Processing Workflow

  1. Prepare the workspace

    Create the html-editor directory and place the project files and website copy in it.

  2. Build the runtime image

    Build the html-editor image using the Dockerfile, Python 3.12 slim and BeautifulSoup.

  3. Create and revise the script

    Use Nano to create or edit edit_html.py.

  4. Discover the input files

    The first execution reported 354 HTML files.

  5. Clean the HTML pages

    The second execution reported 353 removals for each of the three target IDs.

  6. Write the output

    The script reported saving processed files in websitename-cleaned.

Final Results

The final successful processing run reported:

354 HTML files discovered
353 Header elements removed
353 Sidebar elements removed
353 Footer elements removed
Reported status: Cleanup complete!

Reported output path: /app/websitename-cleaned

The log does not explain why each removal count was 353 rather than 354. The counts do not establish that all 354 files contained all three elements.

Accessing the Output

The script reported the output directory as /app/websitename-cleaned. However, the /app path is inside the Docker container. It is not the direct path used by the macOS host shell.

Incorrect host-side command

cd /app/websitename-cleaned

This command failed in the host shell because /app is the container mount point.

Correct host-side commands

cd ~/html-editor/websitename-cleaned
ls

Assuming the project is located in ~/html-editor, these commands navigate to the output directory and list its contents.

The transcript does not show a successful listing of the output directory. Its contents were therefore not independently verified in the recorded session.

Stopping Docker Desktop on macOS

After the cleanup and verification are complete, Docker Desktop can be stopped.

Option 1: Using Terminal

osascript -e 'quit app "Docker"'

Asks macOS to quit the Docker Desktop application.

Option 2: Using the Docker Desktop menu

  1. Click the Docker whale icon in the macOS menu bar.
  2. Select Quit Docker Desktop.

Verify that Docker has stopped

docker info >/dev/null 2>&1 && echo "Docker is running" || echo "Docker is not running"

Expected output after Docker Desktop has fully stopped:

Docker is not running

This command suppresses normal output and error messages from docker info. It checks whether the Docker CLI can communicate with the Docker daemon. If Docker Desktop is still shutting down, wait briefly and run the check again.

Important Docker notes
  • Quitting Docker Desktop stops the Docker daemon and its running containers.
  • The --rm option removes the temporary container after it exits. It does not remove the html-editor image.
  • The cleaned HTML files are stored in the mounted host project directory. Quitting Docker Desktop does not delete those files.
  • Start Docker Desktop again and wait for its engine to become available before running more Docker commands.

Notes and Limitations

  • This documentation is based on the supplied terminal transcript and project report.
  • The exact contents of Dockerfile and edit_html.py were not included.
  • The log confirms that the Docker image built and the script reported Cleanup complete!.
  • No before-and-after HTML comparison was included.
  • No browser-based validation was included to confirm that all pages render correctly after cleanup.
  • The log reports 354 discovered HTML files and 353 removals for each target ID. It does not explain the difference.
  • The output directory was reported by the script, but its contents were not independently verified in the recorded session.

Conclusion

A Docker-based Python environment was successfully prepared and used to process a local collection of website HTML pages. The processing script found 354 HTML files and reported removing header, sidebar and footer elements 353 times each.

The cleaned output was directed to websitename-cleaned. The command-line issue occurred afterward, when a container-internal path was used from the host macOS shell. This path issue does not indicate that the cleanup operation itself failed.

The workflow can be completed by checking the output directory on the host Mac and quitting Docker Desktop when no further container work is required.