viernes, 17 de enero de 2025

mongodb initialization

 

  1. Start MongoDB without access control.

     mongod --port 27017 --dbpath /data/db1
    
  2. Connect to the instance.

     mongosh --port 27017
    
  3. Create the user administrator.

     use admin
     db.createUser(
       {
         user: "myUserAdmin",
         pwd: passwordPrompt(), // or cleartext password
         roles: [ 
           { role: "userAdminAnyDatabase", db: "admin" },
           { role: "readWriteAnyDatabase", db: "admin" } 
         ]
       }
     )
    
  4. Re-start the MongoDB instance with access control.

     mongod --auth --port 27017 --dbpath /data/db1
    
  5. Authenticate as the user administrator.

     mongosh --port 27017 --authenticationDatabase "admin"\
         -u "myUserAdmin" -p 
    

lunes, 13 de enero de 2025

Developing in devcontainer: How to access local network of host

 To connect your devcontainer to the local network, you must consider use runArgs!!

  1. Edit .devcontainer/devcontainer.json and add "--network=host" to the runArgs array
  2. Rebuild your dev container (command palette → Remote Containers: Rebuild Container)
  3. (re)Start Home Assistant (command palette → Tasks: Run Task → Run Home Assistant Core)

Your dev container should then be connected to your host network.

 

More about...

https://containers-dev.translate.goog/implementors/json_reference/?_x_tr_sl=en&_x_tr_tl=es&_x_tr_hl=es&_x_tr_pto=tc

martes, 7 de enero de 2025

Azure DevOps without docker permissions

 If you are trying to run azure devops and run a container. Maybe you can find this issue:

permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

This is an error based on the user that is running the agent service. For this reason, you should check which user is running the service.

$ ps aux |grep agent

admin     2736  0.0  0.0   7340  2048 ?        Ss   Jan06   0:00 /bin/bash /home/admin/azagent/runsvc.sh

admin     2747  0.0  3.9 274117020 81476 ?     Sl   Jan06   0:16 /home/admin/azagent/bin/Agent.Listener run --startuptype service

admin     8840  0.0  0.0   6544  2048 pts/0    S+   17:03   0:00 grep --color=auto agent


Check the user of that pid

$ ps -u -p 2736
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND admin     2736  0.0  0.0   7340  2048 ?        Ss   Jan06   0:00 /bin/bash /home/admin/azagent/runsvc.sh


Add the group docker, just in case.

$ sudo groupadd docker
groupadd: group 'docker' already exists

 

Add the user to that group
$ sudo usermod -aG docker admin


$ reboot


Try again after the reboot.