Custom configfile when run via Docker

300 views
Skip to first unread message

Eugene Weber

unread,
Apr 26, 2021, 9:40:35 AM4/26/21
to mountebank-discuss
Since I have no access to inner mountebank files when it's run via Docker, I need to store some functions in a custom file. Unfortunately, I cannot set it as a configfile.

When I start mb from yml-file with command: --allowInjection --configfile "/home/user/MyBeautifulConfig.js", it crashes with Error: ENOENT: no such file or directory, open ' /home/user/MyBeautifulConfig.js'

Is there a workaround?

Eugene Weber

unread,
Apr 27, 2021, 5:15:58 AM4/27/21
to mountebank-discuss
It seems like the file path is generated as url: http://localhost:34600/home/user/MyBeautifulConfig.js, which of course does not exist.

понедельник, 26 апреля 2021 г. в 16:40:35 UTC+3, Eugene Weber:

Craig Harris

unread,
Apr 27, 2021, 11:38:04 AM4/27/21
to Eugene Weber, mountebank-discuss
Hi Eugene,

The concept you are looking for in bind mounts. This is the ability for a docker container to access the host file system when executing.
The default (for very good security reasons) is to not allow any access.
You will need to specify exactly which folders on the host O/S are available inside the container. You also need to specify where this folder is located (mounted)

docker run -v /home/user:/config

This will make the contents of the /home/user folder available inside the container as /config

Therefore you would change the MB line to --configfile "/config/MyBeautifulConfig.js"

Personally I use docker-compose

I create a file called docker-compose.yml
version: "3.7"

services:

    mb:
    image: andyrbell/mountebank:latest
    container_name: mb
    entrypoint: mb start --loglevel info --port 2525 --configfile /config/config.ejs --allowInjection
    ports:
        - 2525:2525
        - 2080:2080
    volumes:
        - .:/templates

I then start up using
docker-compose -d up

docker-compose in its simplest form is simply a way to manage groups of docker containers without needing long command lines in home grown script files

--
You received this message because you are subscribed to the Google Groups "mountebank-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mountebank-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mountebank-discuss/736ae394-d330-4e52-bd8c-9e1c72246653n%40googlegroups.com.

Eugene Weber

unread,
May 5, 2021, 9:21:50 AM5/5/21
to mountebank-discuss
Hi!

Thanks. So you basically add a needed file to docker volumes and it works within docker commands.

вторник, 27 апреля 2021 г. в 18:38:04 UTC+3, craig...@gmail.com:
Reply all
Reply to author
Forward
0 new messages