I'm trying to run a mongodb container on Windows Server 1809 but am getting the following error:
docker run --name mongodb --restart unless-stopped -d -p 27017:27017 mymongo
docker: Error response from daemon: hcsshim::CreateComputeSystem bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316: The container operating system does not match the host operating system.
(extra info: {"SystemType":"Container","Name":"bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316","Owner":"docker","VolumePath":"\\\\?\\Volume{452442a7-ac87-4117-8e82-b00a8d87b444}","IgnoreFlushesDuringBoot":true,"LayerFolderPath":"C:\\ProgramData\\docker\\windowsfilter\\bf9bf4086726d00cbcaff1f082e6b1db12bd803f3ba2c2ca7c0db1e5d75aa316","Layers":[{"ID":"fc52f55a-6f1e-5651-93c6-09c1fcaf7c9a","Path":"C:\\ProgramData\\docker\\windowsfilter\\c9035a2f08cd42f11c3c76895b03021b6d48266d0f86bd083c12fa5f86455e60"},{"ID":"ab78d923-9c41-55fc-92ec-a9330d5db560","Path":"C:\\ProgramData\\docker\\windowsfilter\\c01be26c30f8769641fe00741c162d71bb3305df4c71cbaf138ff2b901ec6b11"},{"ID":"026d80b8-19b3-5c4d-ae3d-35a54251fe3e","Path":"C:\\ProgramData\\docker\\windowsfilter\\def72c2b739b9f453610c44a8ed61e997306eaf34a2ecddd00198d0e7a002f97"},{"ID":"3f241ae1-ba2c-5fec-8d70-c2396e176817","Path":"C:\\ProgramData\\docker\\windowsfilter\\c7cedcded6a8aa587cef67edb4918bec61be7a3500892ea1e96ff7b2c3e13af2"},{"ID":"2efd8648-ea16-508d-8c5b-6a0ef3e6c84d","Path":"C:\\ProgramData\\docker\\windowsfilter\\60049935b45a47f9649619a2f5bcd87d9b9a909452c3bd0fbd1a6a7275bcb7b0"},{"ID":"eddd0e96-fd43-58c7-94fc-530892d35234","Path":"C:\\ProgramData\\docker\\windowsfilter\\80f9aa5efa51e2fa9b068a68b4b5dd5a4b10724cdeab62238dfe7d3f123767d1"},{"ID":"11f58e92-5415-5594-9910-9ff4f59731fb","Path":"C:\\ProgramData\\docker\\windowsfilter\\65f94285263b26ecb465ede59d13113b09e2e31891fc832e2700c00a5902c147"},{"ID":"cedb9cc2-9b4c-5175-bd37-f74b69253886","Path":"C:\\ProgramData\\docker\\windowsfilter\\95cb73e37cc8f93d5e63143c0d0de000cc1af77e498108babaf5ceebd09cebf0"},{"ID":"745ef0c5-ae72-5e25-b6bb-7208c533560e","Path":"C:\\ProgramData\\docker\\windowsfilter\\8984fb6ffe0575d27d836a764d64591ae175272a75260ee476507100618d3b78"},{"ID":"b0dcfd28-95d6-506d-bbcf-48e5f62ef97f","Path":"C:\\ProgramData\\docker\\windowsfilter\\e747665dffb09875cdeeb4438a422f2c6a3a83f3d30f1d77001e19a078ec3392"},{"ID":"f2fb9c30-cdca-513e-8409-c21af8fbfcaa","Path":"C:\\ProgramData\\docker\\windowsfilter\\f5641e2fbb273e21e654e8671af314de80a62f5a5074cfdb3a7784f296c6d171"},{"ID":"67e9a990-1ee4-597f-8e73-ee95b6f65d30","Path":"C:\\ProgramData\\docker\\windowsfilter\\e18aba5da9d71b86e113123d6635fcec544f1228b6c29e76b7027ed1d5b207d7"},{"ID":"741cd5e2-3dfe-5693-ba08-ac8fed4ae741","Path":"C:\\ProgramData\\docker\\windowsfilter\\6029438e12ce66ab4f7b48ca5f7aa10ff6d1b284602f2f6fa0ab2b56daa96796"}],"HostName":"bf9bf4086726","MappedDirectories":[{"HostPath":"C:\\ProgramData\\docker\\volumes\\e1898e25db59a589102c266339cc21243e62ba950a70a82f6b3fc31d693f1494\\_data","ContainerPath":"c:\\data\\configdb","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false},{"HostPath":"C:\\ProgramData\\docker\\volumes\\e42d0b5e649c60b87b7ff283b0db51f28d95cf1e9b2ef33ddb50344bf61358b7\\_data","ContainerPath":"c:\\data\\db","ReadOnly":false,"BandwidthMaximum":0,"IOPSMaximum":0,"CreateInUtilityVM":false}],"HvPartition":false,"EndpointList":["A64F960D-CB2B-4452-8438-2A1E25105432"],"AllowUnqualifiedDNSQuery":true}).
I tried with both 4.2.1-windowsservercore-1803 and 4.2.1-windowsservercore-ltsc2016. I also tried using isolation=hyperv, but it gave me "Request is not supported". On another Windows Server, this one 2016, everything worked.
What can I do to run a mongo container on windows server 1809?
I got it working by copying the image for the MongoDB version I wanted on their github and changing the FROM line to
FROM mcr.microsoft.com/windows/servercore:1809
Related
I am using Docker for Windows which is up to date (v 4.16.2). I also switched to Windows Containers. I wanted to use postgres using this prompt:
docker run --name MyPostgresSQL -p 5432:5432 -e POSTGRES_PASSWORD=12345 -d postgres
Then the log of this MyPostgresSQL is here:
I couldn't even find any question about this error. I tried restarting docker, switching to Linux containers then switching back to Windows containers, purging docker data but any of them didn't work at all.
I created a MongoDB docker instance as follows:
sudo docker run --name mongo -d -p 27000:27000 mongo
I confirmed that the instance is running by using command sudo docker ps --all :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f509276287eb mongo "docker-entrypoint.s…" 2 minutes ago Up 2 minutes 0.0.0.0:27000->27000/tcp, :::27000->27000/tcp, 27017/tcp mongo
Then I tried to connect to it using Compass GUI tool with the following connection string:
mongodb://localhost:27000/
I get a screen the following screen:
and after waiting for a while, the screen disappears with the following error message
connection <monitor> to 127.0.0.1:27000 closed
My goal is to use this docker image to run tests, but I cannot connect to it.
I tried using 0.0.0.0 instead of localhost but it didn't work.
My Question: How do I connect to MongoDB docker image?
Environment info:
OS is Ubuntu 22.04
Docker version 20.10.14, build a224086349 (snap package)
Compass version 1.33.1 (deb package)
I figured it out. I made a silly mistake when picking the port, I should have used:
sudo docker run --name mongo -d -p 27000:27017 mongo
Because Mongo will always be on port 27017 inside the image.
I am using latest MongoDB docker image in Ubuntu Host. Ubuntu version 20.04.
I am using the following command to start the container -
docker run --name local_mongo -d -p 27017:27017 mongo
Whenever I am trying to connect to Mongo Server I am getting the following error..
Any pointer will be helpful...
It is not the right answer but after spending some odd 11 hours found the following solution -
Downgraded the host OS from Ubuntu 20.04 to Ubuntu 18.04.4 LTS.
As per my limited knowledge working inside docker container should not get impacted even though the HOST OS are different. But at the same time I feel HOST to Container communication has changed in Ubuntu 20.04.
Because when I tried connecting MS SQL Server also in Ubuntu 20.04 as HOST my previous setup stopped working as it was working with Ubuntu 18.04.
So can't really comment whether it is a docker daemon issue or container issue. But something has changed.
Please keep posting your findings so that we can have a working solution in Ubuntu 20.04 as HOST.
I'm having docker container up and running by using the following command:
docker run -p 27017:27017 -d mongo
Docker Logs for reference.
Then I clone a github repo: https://github.com/springframeworkguru/spring-boot-mongodb.git
Import the project in IntelliJ IDE, build it and run.
SpringBoot App Error Logs here
Issue : I'm not able to connect to the mongo app running in the container from my SpringBoot application as I'm getting MongoSocketOpenException as shown in the logs.
Any help is appreciated?
Docker version 18.03.0-ce, build 0520e24302
OS: Windows 10
Docker for win has some problems with loopback interfaces.
https://blog.sixeyed.com/published-ports-on-windows-containers-dont-do-loopback/
Try run docker inspect and configure your application with the container address.
Problem: I was trying to configure SpringBoot Application to mongo container IP which I retrieved from mongo inspect <mongo_container> command which was incorrect.
Solution: Configured my application using docker IP retrieved by docker-machine <env> which resolved the problem.
Link to the post is here.
I`m trying to connect to mongodb in docker container from a host ( for dev purposes solely) without any luck.
I have following docker-compose file.
version: '2.2'
services:
mongo:
image: mongo
ports:
- "27017:21017"
And when i try to connect to it i'm getting following error:
C:\Program Files\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
2017-10-25T03:48:53.331+0300 E QUERY [thread1] Error: network error while attempting to run command 'isMaster' on host '127.0.0.1:27017' :
connect#src/mongo/shell/mongo.js:237:13
#(connect):1:6
exception: connect failed
But if i launch it without compose directly e.g.
docker run --name my_mongox6 -d -p 27017:27017 mongo
Which should be equivalent of the docker-compose file above.
And it works perfectly fine
C:\Program Files\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.9
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.9
Server has startup warnings:
2017-10-25T00:49:58.983+0000 I STORAGE [initandlisten]
2017-10-25T00:49:58.983+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2017-10-25T00:49:58.983+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2017-10-25T00:49:59.076+0000 I CONTROL [initandlisten]
2017-10-25T00:49:59.076+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2017-10-25T00:49:59.076+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2017-10-25T00:49:59.076+0000 I CONTROL [initandlisten]
Versions
c:\Program Files\MongoDB\Server\3.4\bin>docker --version
Docker version 17.09.0-ce, build afdb6d4
c:\Program Files\MongoDB\Server\3.4\bin>docker-compose --version
docker-compose version 1.16.1, build 6d1ac219
I'm using docker for windows that is run via hyper-v.
Whats wrong with my compose file and why it works via docker run but doesn't work via docker-compose. I'm scratching my head and googling without any luck for hours
Other port sharing via docker-compose ( e.g. nginx, postgresql) works perfectly fine.
UPDATE
Asked friend on ubuntu to try. Same behaviour. So its reproducible and its not specific to windows at all.. Works via docker, doesnt work via docker-compose. Even when i try to connect via telnet mongo logs show connect attempts when running via docker, but nothing shown when run via compose.
Also I see a difference in docker ps when run via compose vs when run via docker.
Ports on compose listed as
( 27017/tcp, 0.0.0.0:27017->21017/tcp )
vs
(0.0.0.0:27017->21017/tcp )
on docker itself.
It missed first 27017/tcp part which might be the issue, but no idea why.
Ok, the problem is super stupid and simple.
ports: - "27017:21017"
second port 21017 instead of 27017. How to waste full day due to typo
If you are on linux it works fine. When you run container in windows you need to do port farwarding.
netsh interface portproxy add v4tov4 listenport=27017 listenaddress=localhost connectport=27017 connectaddress=192.168.99.100(IP of the Docker)
Whatever the call comming to loopback it will get redirected to container with the docker host.
Here is the helping discussion on port farwarding in windows with docker Solution for Windows hosts
This lines I'm using docker for windows that is run via hyper-v., say that you ae on Windows and docker will not be the loopback(127.0.0.1), you have to forward the port.