Search code examples
dockerejabberd

Command to open ejabberd default configuration (conf) file in Docker


I am trying to reach the default configuration file of ejabberd in docker to define my admin user, as it is done in Linux or in Windows using putty

# sudo vi /opt/ejabberd-16.09/conf/ejabberd.yml

I am following ejabberd-docker doc and found quite a helping material

docker run -d --name ejabberd -v $(pwd)/ejabberd.yml:/home/ejabberd/conf/ejabberd.yml -v $(pwd)/database:/home/ejabberd/database -p 5222:5222 ejabberd/ecs

but unable to find the exact command to open the default conf file for ejabberd in docker like it is done using Putty or in Linux system. thanks for your time and help


Solution

  • Usually containers do not have a sshd running, therefore you should not attempt to connect to a container using putty.

    Instead, list your containers:

    docker ps
    CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                                                                           NAMES
    2570a852e4c1        ejabberd/ecs        "/home/ejabberd/bin/…"   2 minutes ago       Up 2 minutes        1883/tcp, 4369-4399/tcp, 5269/tcp, 5280/tcp, 5443/tcp, 0.0.0.0:5222->5222/tcp   ejabberd
    

    then use an interactive terminal(-it) to get inside the container and explore things:

    docker exec -it 2570a852e4c1 sh
    

    then check the contents of your file:

    ~ $ cat /home/ejabberd/conf/ejabberd.yml
    ###
    ###              ejabberd configuration file
    ###
    ### The parameters used in this configuration file are explained at
    ###
    ###       https://docs.ejabberd.im/admin/configuration
    

    OR

    Just execute the cat to see the content of the file, without even using an interactive terminal:

    docker exec 2570a852e4c1 cat /home/ejabberd/conf/ejabberd.yml
    

    According to your docker run command, you are mounting the ejabberd.yml file from your host's working directory(relative to where you're running the command) into the container at /home/ejabberd/conf/ejabberd.yml.
    Changing this file inside the container will change the file on the host and vice-versa, therefore you can explore or write that config directly on the host.