Dockerfile: how to set env variable from file contents

Environment Variables If you want to set a number of environment variables into your docker image (to be used within the containers) you can simply use env_file configuration option in your docker-compose.yml file. With that option, all the entries in the .env file will be set as the environment variables in image and hence into … Read more

Achieve Local Function

Bash does not support local functions, but depending on your specific script and architecture you can control the scope of your function name through subshells. By replacing the {..} with (..) in your definition, you’ll get the output you want. The new definition of usage will be limited to the function, but so will e.g. … Read more

Adding users to sudoers through shell script

You could simply echo (with elevated privileges, of course) directly to the /etc/sudoers file: sudo -i echo ‘nickw444 ALL=(ALL:ALL) ALL’ >> /etc/sudoers # ^^ # tab (note the tab character between the username and the first ALL) Or, for a script: #!/bin/bash # Run me with superuser privileges echo ‘nickw444 ALL=(ALL:ALL) ALL’ >> /etc/sudoers Then … Read more

tech