Menu ▾ ▴

#1339 Question: how to use a Mongo instance with authentication?

closed
nobody
None
6 minutes ago
22 minutes ago
No

I would like to setup a Wekan Docker container on my synology. Problem is my Mongo DB has authentication enabled because I use it for other products (Leanote for example).

All examples of Wekan Dockerfile I found use the deprecated "--link" instructions, and even while looking inside the Dockerfile it self, I can't figure out how to specify Mongo IP, port, database name, user and password.

I probably miss something, but didn't find anything really useful for this.
Thanks.


Mirrored from https://github.com/wekan/wekan/issues/1375.
Source: http://localhost:2000/wekan/wekan/issues/1375.
Original author: romu70; created: 2017-12-02T19:29:02+02:00.

Discussion

  • Lauri Ojansivu

    Lauri Ojansivu - 21 minutes ago

    @romu70

    You probably use some MongoDB authentication URL for all your other products, so you need to setup environment variable to your existing MongoDB container before starting Wekan Docker container. Wekan can use any existing MongoDB inside or outside of Docker, just provide correct MongoDB URL to database name to use. So you only need to start Wekan Docker container.

    Examples:
    https://github.com/wekan/wekan-maintainer/blob/master/virtualbox/start-wekan.sh#L5
    https://github.com/wekan/wekan-mongodb/blob/master/docker-compose.yml#L80

    Starting only Wekan container, example modified from without link to MongoDB container like at
    https://github.com/wekan/wekan/wiki/Docker
    so in this case you would use command line like this to run Wekan on port 8080, mapping to only localhost so port is not exposed to local network. If you would like to expose it to local network, add server IP address there. Then you would need to use some webserver like at Docker production setup to provide proxy to Wekan, look at Wekan GitHub wiki for configuration examples of various webservers.

    If you use directly Wekan IP address and port at http://192.168.1.200:8080 at local network:

    docker run -d --restart=always --name wekan -e "MONGO_URL=mongodb://127.0.0.1:27017/wekan" -e "ROOT_URL=http://192.168.1.200:8080" -e "PORT=8080" -p 8080:80 wekanteam/wekan:latest
    

    If you have some webserver at front of Wekan proxying to Wekan at localhost 8080, and have Nginx configured for example to http://192.168.1.200/wekan, you could use this:

    docker run -d --restart=always --name wekan -e "MONGO_URL=mongodb://127.0.0.1:27017/wekan" -e "ROOT_URL=http://192.168.1.200/wekan" -e "PORT=8080" -p 8080:80 wekanteam/wekan:latest
    

    If you have some name in your LAN computers /etc/hosts files pointing to your local server IP address, like this line:

    192.168.1.200 wekan
    

    Then you could use url http://wekan to access local Wekan, having server_name wekan; in your nginx config, and start Wekan this way:

    docker run -d --restart=always --name wekan -e "MONGO_URL=mongodb://127.0.0.1:27017/wekan" -e "ROOT_URL=http://wekan" -e "PORT=8080" -p 8080:80 wekanteam/wekan:latest
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18179.
    Original author: xet7; created: 2017-12-02T20:10:09+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    @romu70

    Please reopen issue if you still have problems with this.


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18181.
    Original author: xet7; created: 2017-12-02T21:03:52+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Thanks a lot @xet7 . I tweaked a bit your first command to run this:

    docker run -d --restart=always --name wekan-v0.60 -e "MONGO_URL=mongodb://wekan:blablabla@mymongo_IP:27017/wekan" -e "ROOT_URL=http://myserver_IP:4300" -e "PORT=4300" -p 4300:80 wekanteam/wekan:v0.60
    

    The container output is this:

    2017-12-03 17:45:21 stdout  > Finishing add-sort-checklists migration.
    2017-12-03 17:45:21 stdout  > Starting add-sort-checklists migration.
    2017-12-03 17:45:21 stdout  > Finishing add-member-isactive-field migration.
    2017-12-03 17:45:21 stdout  > Starting add-member-isactive-field migration.
    2017-12-03 17:45:21 stdout  > Finishing denormalize-star-number-per-board migration.
    2017-12-03 17:45:21 stdout  > Starting denormalize-star-number-per-board migration.
    2017-12-03 17:45:21 stdout  > Finishing use-css-class-for-boards-colors migration.
    2017-12-03 17:45:21 stdout  > Starting use-css-class-for-boards-colors migration.
    2017-12-03 17:45:21 stdout  > Finishing card-covers migration.
    2017-12-03 17:45:20 stdout  > Starting card-covers migration.
    2017-12-03 17:45:20 stdout  > Finishing change-attachments-type-for-non-images migration.
    2017-12-03 17:45:20 stdout  > Starting change-attachments-type-for-non-images migration.
    2017-12-03 17:45:20 stdout  > Finishing lowercase-board-permission migration.
    2017-12-03 17:45:20 stdout  > Starting lowercase-board-permission migration.
    2017-12-03 17:45:20 stdout  > Finishing board-background-color migration.
    2017-12-03 17:45:20 stdout  > Starting board-background-color migration. 
    

    So I guess some things are pretty normal, right? But when I connect http://myserver_IP:4300, I get:

    Connection reset
    

    CPU is below 1% and memory around 130 MB. How can I debug? Thanks.


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18182.
    Original author: romu70; created: 2017-12-03T19:57:50+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    @romu70

    Container output means that connection to database was succesful and Wekan is able to save data to database.

    Do you have port 4300 open on your Synology NAS ?


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18183.
    Original author: xet7; created: 2017-12-03T20:05:06+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    You can see Docker logs by using container name or ID:

    docker logs wekan-v0.60
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18184.
    Original author: xet7; created: 2017-12-03T20:06:16+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    I don't run a firewall on my Syno. I run some other containers on port 4000, 4100 4200, ...without any problem.

    Is there something I can try to diagnose by connecting the container itself?


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18185.
    Original author: romu70; created: 2017-12-03T20:06:41+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Yes, going inside container:

    docker exec -it wekan-v0.60 bash
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18186.
    Original author: xet7; created: 2017-12-03T20:07:48+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Docker logs are the one I provided above.

    I know this command, but I need some specific Wekan commands to analyse the problem.


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18187.
    Original author: romu70; created: 2017-12-03T20:08:48+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    To see running processes inside container:

    top
    

    To see what is on open port outside container, or some processes

    sudo netstat -plant | grep :4300
    sudo netstat -plant | grep node
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18188.
    Original author: xet7; created: 2017-12-03T20:12:21+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    I'm was the docker command syntax correct to open port correctly to outside container, you could compare it to how other docker contaieners are setup in your system, outside docker:

    docker ps
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18189.
    Original author: xet7; created: 2017-12-03T20:13:48+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    On the host:

    ~# netstat -anp | grep 4300
    tcp6       0      0 :::4300                 :::*                    LISTEN      6436/docker-proxy 
    

    So obviously, there is something which runs.

    From within the container:

    top - 18:32:45 up 12:01,  0 users,  load average: 1.24, 1.49, 1.51
    Tasks:   3 total,   1 running,   2 sleeping,   0 stopped,   0 zombie
    %Cpu(s):  6.8 us,  2.9 sy,  0.0 ni, 90.2 id,  0.1 wa,  0.0 hi,  0.0 si,  0.0 st
    KiB Mem:   4042416 total,  2093424 used,  1948992 free,   158036 buffers
    KiB Swap:  4521908 total,        0 used,  4521908 free.  1132136 cached Mem
    
      PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                 
        1 root      20   0 1045508 111548  10140 S   0.0  2.8   0:20.31 node                                                                    
       23 root      20   0   20236   1912   1460 S   0.0  0.0   0:00.01 bash                                                                    
       28 root      20   0   21944   1416   1036 R   0.0  0.0   0:00.00 top 
    

    So Node runs.

    docker ps output on the host:

    CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                      NAMES
    fa168344a015        wekanteam/wekan:v0.60     "node /build/main.js"    About an hour ago   Up 24 minutes       0.0.0.0:4300->80/tcp       wekan-v0.60
    539df8fd2b17        leanote:2.5               "/app/leanote-linu..."   5 days ago          Up 12 hours         0.0.0.0:4200->9000/tcp     leanote-2.5
    8cc367ce76b6        mongo:3.4.10              "docker-entrypoint..."   5 days ago          Up 12 hours         0.0.0.0:27017->27017/tcp   mongo-3.4.10
    57f1f8862279        wallabag/wallabag:2.2.3   "/entrypoint.sh wa..."   5 months ago        Up 12 hours         0.0.0.0:4000->80/tcp       wallabag-2.2.3
    712f21b28301        miniflux:1.2.3            "supervisord -c /e..."   5 months ago        Up 12 hours         0.0.0.0:4100->80/tcp       miniflux-1.2.3
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18190.
    Original author: romu70; created: 2017-12-03T20:35:28+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Hmm, there is problem that inside container it goes to 4300 and not 80.
    To fix it, remove inside port option this way:

    docker stop wekan-v0.60
    
    docker rm wekan-v0.60
    
    docker run -d --restart=always --name wekan-v0.60 -e "MONGO_URL=mongodb://wekan:blablabla@mymongo_IP:27017/wekan" -e "ROOT_URL=http://myserver_IP:4300" -p 4300:80 wekanteam/wekan:v0.60
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18191.
    Original author: xet7; created: 2017-12-03T20:42:35+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Good catch!! Thanks a lot, it works.


    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18192.
    Original author: romu70; created: 2017-12-03T20:47:28+02:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    After spend a lot time trying discover why wekan docker image didn't work, I discovered that Wekan don't work if you configure PORT value less then 3000 (I think this is a Node.js limitation). So, I solved configuring PORT igual 3000 and mapping inside of my server:

    docker run -d \
            --restart=always \
            --name wekan \
            -e "MONGO_URL=mongodb://localhost/wekan" \
            -e "ROOT_URL=http://localhost/" \
            -e "PORT=3000" \
            -e "WITH_API=true" \
            -e "BROWSER_POLICY_ENABLED=true" \
            -e "TRUSTED_URL=''"\
            -p 80:3000 \
            mquandalle/wekan
    

    For the Dockerfile:

    FROM mquandalle/wekan
    
    # env var settings
    ENV ROOT_URL http://localhost
    # wekan is a node app then It can run in a port < 3000, the port need be >=3000
    ENV PORT 3000
    ENV MONGO_URL mongodb://localhost/wekan
    
    # # == EMAIL SETTINGS ==
    # # Email settings are required in both MAIL_URL and Admin Panel,
    # #   see https://github.com/wekan/wekan/wiki/Troubleshooting-Mail
    # #   For SSL in email, change smtp:// to smtps://
    # # NOTE: Special characters need to be url-encoded in MAIL_URL.
    # #---------------------------------------------------------------
    # ENV MAIL_URL smtp://user:pass@mailserver.example.com:25/
    # ENV MAIL_FROM Example Wekan Support <support@example.com>
    # #---------------------------------------------------------------
    # # == WEKAN API ==
    # # Wekan Export Board works when WITH_API='true'.
    # # If you disable Wekan API, Export Board does not work.
    ENV WITH_API true
    # # Enable browser policy and allow one trusted URL that can have iframe that has Wekan embedded inside.
    # # Setting this to false is not recommended, it also disables all other browser policy protections
    # # and allows all iframing etc. See wekan/server/policy.js
    ENV BROWSER_POLICY_ENABLED true
    # # When browser policy is enabled, HTML code at this Trusted URL can have iframe that embeds Wekan inside.
    ENV TRUSTED_URL ''
    
    # Expose HTTP and HTTPS ports
    EXPOSE 3000 27017
    

    For captain-definition file, if you are using Captain Duck Duck (https://captainduckduck.com/):

    {
        "schemaVersion" :1 ,
        "dockerfileLines" :[
            "FROM mquandalle/wekan",
            "ENV ROOT_URL http://wekan.app.polotto.cloud",
            "ENV PORT 3000",
            "ENV MONGO_URL mongodb://admin:dPTtT4hgdNHMZAHn64YZWchk@srv-captain--wekandb/admin",
            "ENV WITH_API true",
            "ENV BROWSER_POLICY_ENABLED true",
            "ENV TRUSTED_URL ''",
            "EXPOSE 3000 27017"
        ]
    }
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18193.
    Original author: polotto; created: 2018-08-16T20:37:31+03:00.

     
  • Lauri Ojansivu

    Lauri Ojansivu - 6 minutes ago

    Examples of MongoDB with authentication

    MONGO_URL=mongodb://username:password@127.0.0.1:27017/wekan
    
    MONGO_URL=mongodb://username:password@192.168.0.200:27017/wekan
    
    MONGO_URL=mongodb://username:password@dbserver.mongohosting.com:27017/wekan
    

    Mirrored from http://localhost:2000/wekan/wekan/issues/1375#issuecomment-18195.
    Original author: xet7; created: 2025-02-07T15:53:16+02:00.

     

Log in to post a comment.