Wine: Using Bottles

Something I often see mentioned, but rarely explained, is the concept of Wine (which is not an emulator) bottles. Once I was able to understand the concept, it became much easier to run (certain) Windows applications in Linux. Let me share a little.

A Wine “bottle" is a collection of Wine libraries, settings, and applications. One can run as many bottles as the hard drive will hold. The bottle concept is important because the modifications one might make to enable application “A" can totally hose application “B". There are some configuration options within a bottle that can be set on an application level, but when you need to over-write a certain DLL in the System32 folder or use a non-standard audio driver, or some similar low level change, you are going to want to do that in a separate bottle.

You can start using bottles at any time. Just install Wine in whatever manner works best for you, or start with what you have if it’s already installed. One thing to note is that, with most GUI desktops, the Wine bottle referred to by the CLI and configuration tool is the “default" bottle. Unless you specifically direct a command to a different bottle, all changes are to the default.

To invoke (call or reference) a non-default bottle, you must first open up the CLI and enter something like this:

export WINEPREFIX=$HOME/.wine-test

The default Wine bottle is stored someplace like ~/.wine. In this case, we are invoking a new bottle called “.wine-test". Once you “export" your Wine prefix, any commands entered into that CLI window will be applied only to the invoked bottle, and all other bottles will be unimpacted.

To install an application into this new bottle, launch the installation file from this same window using the wine command:

wine ~/downloads/testsetup.exe

Once the installation completes, the application will be stored in the Program Files sub-directory of the new bottle.

e.g.

.wine
.wine-test
     Program Files
          Common Files
          Internet Exploration
          Test Application
    users
    Windows
     ...

Since the Wine configuration tool in your GUI menu system only impacts the “.wine" bottle, you’ll need to call the new bottle’s configuration tool from this same CLI window, again, after issuing the export command.

export WINEPREFIX=$HOME/.wine-test
winecfg

From here, you would set all the normal Wine configurations like DLL overrides, video and audio driver choices, and Windows version. Hit “Apply" and close the tool when you are done, and the changes have been made to your bottle.

To make registry changes to the new bottle, invoke it and call regedit:

export WINEPREFIX=$HOME/.wine-test
regedit

Note that using export prefix means the WINEPREFIX environment needs to be explicitly set only once per CLI session. As long as that CLI window is open, any Wine commands will only reference the invoked bottle. If you close the window, and open a new one without setting the environment, any subsequent commands would be applied to the default “.wine" bottle. This applies also to tools like winetricks or PlayOnLinux. Alternately, you can call WINEPREFIX alone in-line with any command to set the environment and then forget it immediately.

WINEPREFIX=$HOME/.wine-test winetricks win2k
WINEPREFIX=$HOME/.wine-othertest winetricks vista 

A final note on the use of bottles. Once an application’s usefulness has passed, you’ll generally want to un-install it to free up resources. This will often not work well in Wine, especially if the original installation wasn’t a complete success or the application has become otherwise corrupt. Bottles offer a short-cut solution: delete the bottle and everything within it - registry, applications, and system files - is gone. Run an export command and you start over clean.

Comments

Thanks, this was really helpful :)

Thanks from me as well. This is exactly what I was looking for. I've seen other gloss-over references, but wanted to know how to really use it.