Skip to content

1.10 Docker Misc 2

1. Containerizing Windows apps

To containerize an application like Notepad++ and distribute it, you can follow these steps using Docker:

1. Install Docker

Make sure Docker is installed on your system. You can download it from the Docker website.

2. Create a Dockerfile

Create a Dockerfile to define the container’s environment. Here’s an example Dockerfile for Notepad++:

# Use a base image with Wine (to run Windows apps)
FROM jlesage/wine
# Set environment variables for Notepad++
ENV NPP_VERSION 8.5.3
ENV NPP_URL https://github.com/notepad-plus-plus/notepad-plus-plus/releases/download/v${NPP_VERSION}/npp.${NPP_VERSION}.Installer.exe
# Download Notepad++
RUN wget ${NPP_URL} -O /tmp/npp_installer.exe && \
wine /tmp/npp_installer.exe /S && \
rm -f /tmp/npp_installer.exe
# Set Notepad++ as the default app
ENTRYPOINT ["wine", "C:\\Program Files\\Notepad++\\notepad++.exe"]

3. Build the Docker Image

In the directory containing the Dockerfile, run the following command to build the image:

Terminal window
docker build -t notepadpp-container .

4. Run the Docker Container

Once the image is built, you can run the container:

Terminal window
docker run -d --name notepadpp notepadpp-container

5. Distribute the Container

To distribute the application:

  • Push to Docker Hub: Tag the image and push it to a repository like Docker Hub.

    Terminal window
    docker tag notepadpp-container your-dockerhub-username/notepadpp
    docker push your-dockerhub-username/notepadpp
  • Export as Tar: Alternatively, you can export the Docker image to a .tar file for distribution.

    Terminal window
    docker save -o notepadpp-container.tar notepadpp-container

Users can then download or pull the image and run it on their systems.

2. Windows App Support in Linux Systems

The jlesage/wine Docker image is designed to run Windows applications on Linux-based systems using Wine (a compatibility layer that allows running Windows applications on Linux). This image provides a pre-configured environment that simplifies the process of running Windows executables in a container, making it ideal for containerizing GUI-based Windows applications like Notepad++.

Key Features of jlesage/wine:

  1. Pre-installed Wine:

    • Wine is already installed and configured within the image, so you don’t have to worry about setting up Wine manually.
  2. GUI Application Support:

    • It supports running GUI-based applications in containers by leveraging VNC (Virtual Network Computing). The GUI of the Windows app can be accessed via a web browser or a VNC client.
  3. Base Image:

    • The image is based on Alpine Linux, a lightweight Linux distribution. This helps keep the container size relatively small while providing the necessary tools to run Windows apps.
  4. VNC and Web Interface:

    • It includes a VNC server so that you can access the GUI of the application inside the container through a VNC client or even a web-based VNC viewer via a browser.
    • For example, once the container is running, you can access the app GUI by opening http://localhost:5800 in your browser.
  5. Easy Customization:

    • The image allows for customization by adding your own applications or scripts to be run with Wine, as demonstrated in the example Dockerfile.
  6. Persistent Storage:

    • It includes support for mounting directories to ensure persistent storage. You can mount volumes to keep the installed apps, configuration files, or data across container restarts.

Usage

Here’s how to use the jlesage/wine image to run a Windows application:

1. Pull the Docker Image:

Terminal window
docker pull jlesage/wine

2. Run the Container with a VNC Server:

You can run the container and expose ports for VNC access:

Terminal window
docker run -d -p 5800:5800 -p 5900:5900 jlesage/wine
  • Port 5800 is for the web-based VNC viewer (accessible via a browser).
  • Port 5900 is for accessing the VNC server with a VNC client.

3. Access the Application:

Once the container is running, you can open your browser and access the Wine GUI environment at:

http://localhost:5800

4. Running Applications:

You can launch and install Windows applications inside the container. For example, you can use Wine’s command line to run .exe files:

Terminal window
docker exec -it <container_name> wine <path_to_exe_file>

Example Use Case

In a typical use case like Notepad++, you would:

  1. Pull the jlesage/wine image.
  2. Create a Dockerfile that installs Notepad++ or any other Windows app.
  3. Build and run the container, and then access the app through a browser or VNC client.

Customization Options:

  • Volume Mounting: You can mount local directories into the container for persistent data storage:

    Terminal window
    docker run -d -p 5800:5800 -v /path/to/local/dir:/config jlesage/wine

    This will allow you to keep the configuration and application data across container restarts.

  • Environment Variables: You can pass environment variables to customize things like resolution, VNC password, etc. For example:

    Terminal window
    docker run -d -p 5800:5800 -e DISPLAY_WIDTH=1280 -e DISPLAY_HEIGHT=1024 jlesage/wine

Additional Resources:

  • GitHub Repository: For more details, you can check the official GitHub repository for jlesage/wine here.