docker-wine
docker-wine copied to clipboard
How do you install Windows software in a Dockerfile?
Hi @scottyhardy ,
I have another query. How do we build a docker image with pre-installed windows software? Is there a way to do this via Dockerfile?
Thanks
Originally posted by @ggkunka in https://github.com/scottyhardy/docker-wine/issues/89#issuecomment-667499005
Hi @scottyhardy , Could you please provide some pointers here on how this could be accomplished? So that I could try something before we have the actual documentation? Thank you!
Hi @ggkunka, I think the solution provided in #88 is probably the best method and the one I'd test first. In short, just include
ARG TERM=dumb
RUN wineconsole --backend=curses /path/to/file.exe
Just be aware that on the first run of wine
(or wineconsole
) the gecko
and mono
packages are installed which can take some time (see #87)
https://github.com/scottyhardy/docker-wine/issues/88#issuecomment-669442973 shows another alternative using X11 but probably not so great for automated builds. I’d substitute xvfb for an X server if it was totally necessary for an X server to be present for the install but I can’t think of any situations where you couldn’t just use wineconsole instead
Hi @scottyhardy ,
I added my code post the lines
RUN chmod +x /root/download_gecko_and_mono.sh
&& /root/download_gecko_and_mono.sh "$(dpkg -s wine-${WINE_BRANCH} | grep "^Version:\s" | awk '{print $2}' | sed -E 's/~.*$//')"
ARG TERM=dumb RUN wineconsole --backend=curses /root/IPSL/IPSLTools-3.1.2.exe
I'm getting errors related to the X server and finally it says Could not find Wine Gecko. HTML rendering will be disabled. Please see attachment. I'm a bit confused. The download_gecko_and_mono.sh uses wget and downloads the files. But at what point is this getting installed? I don't see the installation command in entrypoint script too. Could you please guide me here? Am I missing something?
Thank You!
Note: I'm using Ubuntu 18.04 on WSL2. I have also enabled xrdp and also tried the build via the rdp session. But yet I encounter the same error.
Hi @ggkunka - I've been playing around with automating installs and this is an example of what I've come up with so far.
FROM scottyhardy/docker-wine:latest
# Optional - many older apps require 32-bit arch
ENV WINEARCH=win32
RUN xvfb-run winetricks -q 7zip
ENTRYPOINT ["/usr/bin/entrypoint", "wine", "C:\\Program Files\\7-Zip\\7zFM.exe"]
You could then build and run this container with the following:
docker build -t wine-7zip -f Dockerfile.7zip_example .
./docker-wine --local=wine-7zip --as-root
So to create your own dockerfile, first off you need to be able to run your installer in unattended mode. Most Windows installers use /q
or /s
(e.g. wine my_app_installer.exe /q
) or you can use /?
to get a list of available options. I'd recommend testing out your unattended install with a normal interactive docker-wine session first off to make sure it works.
As you can see in the dockerfile, I use xvfb-run
before running the installer. This starts an X session with a virtual frame buffer using display :99 by default - in other words, it allows graphical programs to run in a text-only environment. xvfb-run
is not actually necessary for the 7-zip installer in the example, but it is required in more complicated installs such as the winamp installer plus it stops a bunch of errors/warnings from being listed in your docker build output.
The line ENV WINEARCH=win32
is also not necessary here as 7-zip installs ok in 64-bit but is necessary for some older apps.
The one annoying issue from using this method is that the installation is run as root, so you need to run the container as root as the program is installed under /root/.wine
. It's not a show stopper, but not everything likes to be run as root (like pulseaudio). You could move the files and change perms in the dockerfile, but that limits you to only running the container as a particular user. This may not be a problem depending on your use case, but I'd like to have a more general solution that still allows you to choose who to run the container as with the ./docker-wine
script
Just a note about gecko and mono installers - the download_gecko_and_mono.sh
script just downloads their installers and places them in /usr/share/wine/<app>
. These apps are pre-requisites that are installed automatically on the first run of wine for every wine prefix that's created.
WINEPREFIX
by default is set to ~/.wine
and is where all the Windows files and apps are installed to. You can have more than one WINEPREFIX
but every single prefix needs to have gecko and mono installed. In addition, a prefix that's been set up with a default 64-bit WINEARCH
cannot be changed to 32-bit - you either need to create a new prefix or delete and re-create your current one.
This is why I only download the installers and don't try to pre-populate the wine prefix, as I don't want to dictate a particular WINEPREFIX
or WINEARCH
to use.
Oh and the error Could not find Wine Gecko. HTML rendering will be disabled.
shouldn't appear any more - this was a bug resolved in #93
Can you change stuff around so that download_gecko_and_mono.sh
doesn't need to run and the contents are instead bundled into the Docker image?
@brandonros that’s what happens now but I didn’t explain it very well. The download script is only run during the docker build and the mono and gecko installers are stored under /usr/share/wine in the image.
wine: created the configuration directory '/home/wineuser/.wine' 0048:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002 0048:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002 0048:err:ole:apartment_get_local_server_stream Failed: 0x80004002 0050:err:ole:StdMarshalImpl_MarshalInterface Failed to create ifstub, hr 0x80004002 0050:err:ole:CoMarshalInterface Failed to marshal the interface {6d5140c1-7436-11ce-8034-00aa006009fa}, hr 0x80004002 0050:err:ole:apartment_get_local_server_stream Failed: 0x80004002 0050:err:ole:start_rpcss Failed to open RpcSs service An error occurs when running my own .exe program. How should it be resolved