couchdb-docker icon indicating copy to clipboard operation
couchdb-docker copied to clipboard

Docker for Windows image

Open garrensmith opened this issue 7 years ago • 8 comments

From docker-couchdb: klaemo/docker-couchdb#107

Other official repositories such as mongo and redis are now offering native Windows container images.

What are the plans for offering a CouchDB Windows image?

I have tried to build one myself. When I make the data directory a VOLUME Erlang quits shortly after the container starts. So there appears to be some kind of compatibility problem with CouchDB and Windows containers.

Let me know what information I could collect to diagnose why it doesn't work with native Windows docker.

garrensmith avatar Apr 25 '17 13:04 garrensmith

Comments from original PR by @drnybble: FYI I have logged moby/moby#31524

garrensmith avatar Apr 25 '17 13:04 garrensmith

by @apihlaja: As far as I know, the core issue of Alpine build applies to Windows too (ie. unmaintained mozjs).

Does your mounts work generally? Ie. is this issue narrowed down to CouchDB and/or Erlang? Docker For Windows FAQ suggest it's not as straightforward as it's with Linux host:

Q: Can I share local drives and filesystem with my Docker Machine VMs? A: No, ....

garrensmith avatar Apr 25 '17 13:04 garrensmith

by @drnybble:

As discussed in moby/moby#31524 the cause of failure with Couch 1.6 is a defect in the Erlang version it uses. I have created a Dockerfile for Couch 2.0.0.1 and it works (the problem area of the Erlang code is extensively reworked and no longer has this problem). I am attaching the Dockerfile here if it is useful.

Here it is...relies on you having downloaded the .msi already.
It seems that couchdb 2.0 requires a post-install step to configure the system for single node or clustering. I am still thinking of the best way to do that to avoids lots of errors in the logs about missing databases.

FROM microsoft/windowsservercore

# Switch the default shell used with RUN to PowerShell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop';"]

# REMARK: Temporary workaround for https://github.com/docker/docker/issues/31093
RUN set-itemproperty -path 'HKLM:\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters' -Name ServerPriorityTimeLimit -Value 0 -Type DWord

COPY apache-couchdb-2.0.0.1.msi C:/

# Stop & remove the service that the .msi installs (there are no properties exposed by the .msi to prevent it in the first place)
# We need empty data and log directories to be able make those volumes under Windows but they have contents due to the service having run.
# I was unable to remove the .delete directory in the data directory, so renaming the directories was the easiest solution
# Also bind couchdb to other than localhost
RUN Start-Process 'C:\Windows\System32\msiexec.exe' -ArgumentList '/i C:\apache-couchdb-2.0.0.1.msi /qn' -wait ; \
    Remove-Item 'C:\apache-couchdb-2.0.0.1.msi' ; \
	C:\couchdb\bin\nssm.exe stop 'Apache CouchDB' > $null ; \
	C:\couchdb\bin\nssm.exe remove 'Apache CouchDB' confirm > $null ; \
	mv C:\couchdb\data C:\couchdb\_data ; \
	mv C:\couchdb\var\log C:\couchdb\var\_log ; \
	New-Item -Path C:\couchdb\data -Type directory > $null ; \
	New-Item -Path C:\couchdb\var\log -Type directory > $null ; \
    Copy-Item C:/CouchDB/etc/local.ini C:/CouchDB/etc/local.ini.orig ; \
    cat C:/CouchDB/etc/local.ini.orig | % { $_ -replace ';bind_address = 127.0.0.1', 'bind_address = 0.0.0.0' } | Out-File C:/CouchDB/etc/local.ini -encoding ASCII
	

WORKDIR C:/CouchDB/

VOLUME C:/couchdb/data
VOLUME C:/couchdb/var/log

EXPOSE 5984

CMD ./bin/couchdb.cmd

garrensmith avatar Apr 25 '17 13:04 garrensmith

I can confirm that the Dockerfile is working

thorsten avatar Sep 20 '18 09:09 thorsten

Working here as well. v2.3.1 Thanks much!

erichiller avatar Apr 14 '19 00:04 erichiller

We may simply transition CouchDB on Windows (10) to use Docker under WSL2. We need some performance testing to see if this makes sense, however.

wohali avatar Aug 26 '19 05:08 wohali

We may simply transition CouchDB on Windows (10) to use Docker under WSL2. We need some performance testing to see if this makes sense, however.

This is not good, WSL2 is still far from production in Windows Server, also LCoW is far from production on Windows Server; We need proper windows support of the product and not running a Linux version of it on Windows.

SecDWizar avatar Sep 09 '20 09:09 SecDWizar

Not planning to do this anytime soon.

That said, the Windows port of CouchDB has terrible performance as compared to literally any other platform. It is not intended for production use, and you will have a bad time if you try to scale CouchDB on Windows. We publish the binaries to make development and testing easier.

Improving the performance on Windows would require a concerted effort from Microsoft, working with Ericsson, to improve file-based access on Windows in Erlang, especially when it comes to file locking mechanisms and stdio. We asked about this over 10 years ago, and are still waiting...

wohali avatar Sep 09 '20 21:09 wohali