Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Docker on Windows with WSL2 #299

Open
AqeelMufthyHashim opened this issue Mar 6, 2025 · 2 comments
Open

Fixes for Docker on Windows with WSL2 #299

AqeelMufthyHashim opened this issue Mar 6, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request platform-issue Issue is specific to an OS or desktop
Milestone

Comments

@AqeelMufthyHashim
Copy link

Is your feature request related to a problem? Please describe.
I needed to be able to dockerise the application to run Windows, Mac, and Linux to test some print applications and server listeners we built. But the docker build and run kept failing.
The list of errors I encounter:

  1. Dockerfile COPY from windows to the image would make bash files fails as dos files are CRLF and unix expects LF.
  2. Dockerfile COPY needed to be followed by a chmod statement to make the appropriate files executable
  3. During the make process compiling with the necessary avahi libs kepy failing
  4. Docker on windows via WSL2 has really frustrating errors with systemd even with it enabled leading to issues with avahi-daemon and service management
  5. The ippserver is unuseable without port forwarding

Describe the solution you'd like
An updated Dockerfile with compatibility for Docker on windows via WSL2

  1. use sed to remove the carraige return and using chmod to make the appropriate files as executable
WORKDIR /root/ippsample
RUN find . -type f \( -name "config*" -o -name "install-sh*" \) -exec sed -i 's/\r$//' {} \;
RUN find . -type f \( -name "config*" -o -name "install-sh*" \) -exec chmod +x {} \;
  1. added libavahi-core-dev to list of packages
RUN apt-get install -y  mdns-scan libavahi-core-dev
  1. manually starting the avahi-daemon due to systemd issues
# Create entrypoint.sh script to start dbus and avahi-daemon
RUN echo '#!/bin/bash\n\
service dbus start\n\
avahi-daemon --no-chroot -D\n\
$*\n\
  1. run call to enable port forwarding, adding -p 0.0.0.0:631:631
docker run -it -p 0.0.0.0:631:631 ippsample ippserver -M mymanufacturer -l myloc -m model -n myhost -p 631 -s 72 -vvvv myserver

Additional context
I fully acknowledge that there might be a more appropriate way to do this.

@michaelrsweet michaelrsweet self-assigned this Mar 6, 2025
@michaelrsweet michaelrsweet added enhancement New feature or request platform-issue Issue is specific to an OS or desktop labels Mar 6, 2025
@michaelrsweet michaelrsweet added this to the Stable milestone Mar 6, 2025
@michaelrsweet
Copy link
Contributor

Can you attach your complete Dockerfile to this issue? I don't see any particular issues with adopting those changes but the current Dockerfile tries to optimize the size of the resulting image by splitting the build from the container image, so there are multiple places where we are running apt-get for example...

Thanks!

@AqeelMufthyHashim
Copy link
Author

Can you attach your complete Dockerfile to this issue? I don't see any particular issues with adopting those changes but the current Dockerfile tries to optimize the size of the resulting image by splitting the build from the container image, so there are multiple places where we are running apt-get for example...

Thanks!

Hey man, no problem.
Im still working on this, will keep you posted on anything else I find and anything I might be able to improve. BTW I was considering changing build system for windows, because of the issues in VS2019. I think it has issues with the compiler version interpreting functions and function declarations. (just spit balling here)

#
# Docker container for IPP sample implementations.
#
# Copyright © 2014-2025 by the Printer Working Group.
#
# Licensed under Apache License v2.0.  See the file "LICENSE" for more
# information.
#

# Build using current Ubuntu...
FROM ubuntu:latest AS builder

ARG DEBIAN_FRONTEND=noninteractive
#RUN apt-get -qq update
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y avahi-daemon avahi-utils curl man iputils-ping net-tools tcpdump vim
RUN apt-get install -y build-essential autoconf libavahi-client-dev libjpeg-dev libnss-mdns libpam-dev libpng-dev libssl-dev libusb-1.0-0-dev zlib1g-dev
RUN apt-get install -y  mdns-scan libavahi-core-dev

# Copy source files to image
COPY . /root/ippsample/
WORKDIR /root/ippsample
RUN find . -type f \( -name "config*" -o -name "install-sh*" \) -exec sed -i 's/\r$//' {} \;
RUN find . -type f \( -name "config*" -o -name "install-sh*" \) -exec chmod +x {} \;
RUN ./configure; test -f server/ippserver && make clean; make && make install

# Use latest Ubuntu for run-time image...
FROM ubuntu:latest
ARG DEBIAN_FRONTEND=noninteractive
#RUN apt-get -qq update
RUN apt-get update
RUN apt-get upgrade -y
RUN apt-get install -y avahi-daemon avahi-utils curl man iputils-ping net-tools tcpdump vim
RUN apt-get install -y build-essential autoconf libavahi-client-dev libjpeg-dev libnss-mdns libpam-dev libpng-dev libssl-dev libusb-1.0-0-dev zlib1g-dev
RUN apt-get install -y avahi-daemon avahi-discover avahi-utils libnss-mdns mdns-scan libavahi-client-dev libavahi-core-dev
RUN apt-get install -y  mdns-scan libavahi-core-dev

COPY --from=builder /usr/local /usr/local
RUN ldconfig

# Make changes necessary to run Avahi for DNS-SD support
RUN sed -ie 's/rlimit-nproc=3/rlimit-nproc=8/' /etc/avahi/avahi-daemon.conf
RUN update-rc.d dbus defaults
#RUN update-rc.d avahi-daemon defaults

# Create entrypoint.sh script to start dbus and avahi-daemon
RUN echo '#!/bin/bash\n\
service dbus start\n\
avahi-daemon --no-chroot -D\n\
$*\n\
' > /usr/bin/entrypoint.sh && chmod +x /usr/bin/entrypoint.sh
ENTRYPOINT ["/usr/bin/entrypoint.sh"]

# Export port 8000 for ippserver
EXPOSE 631

Wasn't able to upload the file, github was bugging out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request platform-issue Issue is specific to an OS or desktop
Projects
None yet
Development

No branches or pull requests

2 participants